Mercurial > audlegacy-plugins
annotate src/modplug/sndfile.cxx @ 1539:488f7e6c36ed
Tuple builder for modplug. Someone do me a favour and fix getinfo to do something like the one in console.
author | Tony Vroon <chainsaw@gentoo.org> |
---|---|
date | Thu, 30 Aug 2007 23:38:01 +0100 |
parents | 9549fea94794 |
children | 032053ca08ab c349bd73af71 |
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 * Adam Goode <adam@evdebs.org> (endian and char fixes for PPC) |
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 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
8 #include <math.h> //for GCCFIX |
161 | 9 #include "stdafx.h" |
10 #include "sndfile.h" | |
136
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
11 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
12 #define MMCMP_SUPPORT |
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 #ifdef MMCMP_SUPPORT |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
15 extern BOOL MMCMP_Unpack(LPCBYTE *ppMemFile, LPDWORD pdwMemLength); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
16 #endif |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
17 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
18 // External decompressors |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
19 extern void AMSUnpack(const char *psrc, UINT inputlen, char *pdest, UINT dmax, char packcharacter); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
20 extern WORD MDLReadBits(DWORD &bitbuf, UINT &bitnum, LPBYTE &ibuf, CHAR n); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
21 extern int DMFUnpack(LPBYTE psample, LPBYTE ibuf, LPBYTE ibufmax, UINT maxlen); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
22 extern DWORD ITReadBits(DWORD &bitbuf, UINT &bitnum, LPBYTE &ibuf, CHAR n); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
23 extern void ITUnpack8Bit(signed char *pSample, DWORD dwLen, LPBYTE lpMemFile, DWORD dwMemLength, BOOL b215); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
24 extern void ITUnpack16Bit(signed char *pSample, DWORD dwLen, LPBYTE lpMemFile, DWORD dwMemLength, BOOL b215); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
25 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
26 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
27 #define MAX_PACK_TABLES 3 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
28 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
29 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
30 // Compression table |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
31 static signed char UnpackTable[MAX_PACK_TABLES][16] = |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
32 //-------------------------------------------- |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
33 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
34 // CPU-generated dynamic table |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
35 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
36 // u-Law table |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
37 {0, 1, 2, 4, 8, 16, 32, 64, |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
38 -1, -2, -4, -8, -16, -32, -48, -64}, |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
39 // Linear table |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
40 {0, 1, 2, 3, 5, 7, 12, 19, |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
41 -1, -2, -3, -5, -7, -12, -19, -31} |
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 |
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 ////////////////////////////////////////////////////////// |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
46 // CSoundFile |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
47 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
48 CSoundFile::CSoundFile() |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
49 //---------------------- |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
50 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
51 m_nType = MOD_TYPE_NONE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
52 m_dwSongFlags = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
53 m_nChannels = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
54 m_nMixChannels = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
55 m_nSamples = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
56 m_nInstruments = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
57 m_nPatternNames = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
58 m_lpszPatternNames = NULL; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
59 m_lpszSongComments = NULL; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
60 m_nFreqFactor = m_nTempoFactor = 128; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
61 m_nMasterVolume = 128; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
62 m_nMinPeriod = 0x20; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
63 m_nMaxPeriod = 0x7FFF; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
64 m_nRepeatCount = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
65 memset(Chn, 0, sizeof(Chn)); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
66 memset(ChnMix, 0, sizeof(ChnMix)); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
67 memset(Ins, 0, sizeof(Ins)); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
68 memset(ChnSettings, 0, sizeof(ChnSettings)); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
69 memset(Headers, 0, sizeof(Headers)); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
70 memset(Order, 0xFF, sizeof(Order)); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
71 memset(Patterns, 0, sizeof(Patterns)); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
72 memset(m_szNames, 0, sizeof(m_szNames)); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
73 memset(m_MixPlugins, 0, sizeof(m_MixPlugins)); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
74 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
75 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
76 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
77 CSoundFile::~CSoundFile() |
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 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
80 Destroy(); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
81 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
82 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
83 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
84 BOOL CSoundFile::Create(LPCBYTE lpStream, DWORD dwMemLength) |
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 int i; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
88 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
89 m_nType = MOD_TYPE_NONE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
90 m_dwSongFlags = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
91 m_nChannels = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
92 m_nMixChannels = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
93 m_nSamples = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
94 m_nInstruments = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
95 m_nFreqFactor = m_nTempoFactor = 128; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
96 m_nMasterVolume = 128; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
97 m_nDefaultGlobalVolume = 256; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
98 m_nGlobalVolume = 256; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
99 m_nOldGlbVolSlide = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
100 m_nDefaultSpeed = 6; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
101 m_nDefaultTempo = 125; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
102 m_nPatternDelay = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
103 m_nFrameDelay = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
104 m_nNextRow = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
105 m_nRow = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
106 m_nPattern = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
107 m_nCurrentPattern = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
108 m_nNextPattern = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
109 m_nRestartPos = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
110 m_nMinPeriod = 16; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
111 m_nMaxPeriod = 32767; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
112 m_nSongPreAmp = 0x30; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
113 m_nPatternNames = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
114 m_nMaxOrderPosition = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
115 m_lpszPatternNames = NULL; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
116 m_lpszSongComments = NULL; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
117 memset(Ins, 0, sizeof(Ins)); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
118 memset(ChnMix, 0, sizeof(ChnMix)); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
119 memset(Chn, 0, sizeof(Chn)); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
120 memset(Headers, 0, sizeof(Headers)); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
121 memset(Order, 0xFF, sizeof(Order)); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
122 memset(Patterns, 0, sizeof(Patterns)); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
123 memset(m_szNames, 0, sizeof(m_szNames)); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
124 memset(m_MixPlugins, 0, sizeof(m_MixPlugins)); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
125 ResetMidiCfg(); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
126 for (UINT npt=0; npt<MAX_PATTERNS; npt++) PatternSize[npt] = 64; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
127 for (UINT nch=0; nch<MAX_BASECHANNELS; nch++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
128 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
129 ChnSettings[nch].nPan = 128; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
130 ChnSettings[nch].nVolume = 64; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
131 ChnSettings[nch].dwFlags = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
132 ChnSettings[nch].szName[0] = 0; |
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 if (lpStream) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
135 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
136 #ifdef MMCMP_SUPPORT |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
137 BOOL bMMCmp = MMCMP_Unpack(&lpStream, &dwMemLength); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
138 #endif |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
139 if ((!ReadXM(lpStream, dwMemLength)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
140 && (!ReadS3M(lpStream, dwMemLength)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
141 && (!ReadIT(lpStream, dwMemLength)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
142 && (!ReadWav(lpStream, dwMemLength)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
143 #ifndef MODPLUG_BASIC_SUPPORT |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
144 && (!ReadSTM(lpStream, dwMemLength)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
145 && (!ReadMed(lpStream, dwMemLength)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
146 && (!ReadMTM(lpStream, dwMemLength)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
147 && (!ReadMDL(lpStream, dwMemLength)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
148 && (!ReadDBM(lpStream, dwMemLength)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
149 && (!Read669(lpStream, dwMemLength)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
150 && (!ReadFAR(lpStream, dwMemLength)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
151 && (!ReadAMS(lpStream, dwMemLength)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
152 && (!ReadOKT(lpStream, dwMemLength)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
153 && (!ReadPTM(lpStream, dwMemLength)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
154 && (!ReadUlt(lpStream, dwMemLength)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
155 && (!ReadDMF(lpStream, dwMemLength)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
156 && (!ReadDSM(lpStream, dwMemLength)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
157 && (!ReadUMX(lpStream, dwMemLength)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
158 && (!ReadAMF(lpStream, dwMemLength)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
159 && (!ReadPSM(lpStream, dwMemLength)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
160 && (!ReadMT2(lpStream, dwMemLength)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
161 #endif // MODPLUG_BASIC_SUPPORT |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
162 && (!ReadMod(lpStream, dwMemLength))) m_nType = MOD_TYPE_NONE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
163 #ifdef MMCMP_SUPPORT |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
164 if (bMMCmp) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
165 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
166 GlobalFreePtr(lpStream); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
167 lpStream = NULL; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
168 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
169 #endif |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
170 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
171 // Adjust song names |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
172 for (i=0; i<MAX_SAMPLES; i++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
173 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
174 LPSTR p = m_szNames[i]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
175 int j = 31; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
176 p[j] = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
177 while ((j>=0) && (p[j]<=' ')) p[j--] = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
178 while (j>=0) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
179 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
180 if (((BYTE)p[j]) < ' ') p[j] = ' '; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
181 j--; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
182 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
183 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
184 // Adjust channels |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
185 for (i=0; i<MAX_BASECHANNELS; i++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
186 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
187 if (ChnSettings[i].nVolume > 64) ChnSettings[i].nVolume = 64; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
188 if (ChnSettings[i].nPan > 256) ChnSettings[i].nPan = 128; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
189 Chn[i].nPan = ChnSettings[i].nPan; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
190 Chn[i].nGlobalVol = ChnSettings[i].nVolume; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
191 Chn[i].dwFlags = ChnSettings[i].dwFlags; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
192 Chn[i].nVolume = 256; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
193 Chn[i].nCutOff = 0x7F; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
194 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
195 // Checking instruments |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
196 MODINSTRUMENT *pins = Ins; |
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 for (i=0; i<MAX_INSTRUMENTS; i++, pins++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
199 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
200 if (pins->pSample) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
201 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
202 if (pins->nLoopEnd > pins->nLength) pins->nLoopEnd = pins->nLength; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
203 if (pins->nLoopStart + 3 >= pins->nLoopEnd) |
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 pins->nLoopStart = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
206 pins->nLoopEnd = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
207 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
208 if (pins->nSustainEnd > pins->nLength) pins->nSustainEnd = pins->nLength; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
209 if (pins->nSustainStart + 3 >= pins->nSustainEnd) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
210 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
211 pins->nSustainStart = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
212 pins->nSustainEnd = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
213 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
214 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
215 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
216 pins->nLength = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
217 pins->nLoopStart = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
218 pins->nLoopEnd = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
219 pins->nSustainStart = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
220 pins->nSustainEnd = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
221 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
222 if (!pins->nLoopEnd) pins->uFlags &= ~CHN_LOOP; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
223 if (!pins->nSustainEnd) pins->uFlags &= ~CHN_SUSTAINLOOP; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
224 if (pins->nGlobalVol > 64) pins->nGlobalVol = 64; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
225 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
226 // Check invalid instruments |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
227 while ((m_nInstruments > 0) && (!Headers[m_nInstruments])) m_nInstruments--; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
228 // Set default values |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
229 if (m_nSongPreAmp < 0x20) m_nSongPreAmp = 0x20; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
230 if (m_nDefaultTempo < 32) m_nDefaultTempo = 125; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
231 if (!m_nDefaultSpeed) m_nDefaultSpeed = 6; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
232 m_nMusicSpeed = m_nDefaultSpeed; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
233 m_nMusicTempo = m_nDefaultTempo; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
234 m_nGlobalVolume = m_nDefaultGlobalVolume; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
235 m_nNextPattern = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
236 m_nCurrentPattern = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
237 m_nPattern = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
238 m_nBufferCount = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
239 m_nTickCount = m_nMusicSpeed; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
240 m_nNextRow = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
241 m_nRow = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
242 if ((m_nRestartPos >= MAX_ORDERS) || (Order[m_nRestartPos] >= MAX_PATTERNS)) m_nRestartPos = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
243 // Load plugins |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
244 if (gpMixPluginCreateProc) |
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 for (UINT iPlug=0; iPlug<MAX_MIXPLUGINS; iPlug++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
247 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
248 if ((m_MixPlugins[iPlug].Info.dwPluginId1) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
249 || (m_MixPlugins[iPlug].Info.dwPluginId2)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
250 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
251 gpMixPluginCreateProc(&m_MixPlugins[iPlug]); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
252 if (m_MixPlugins[iPlug].pMixPlugin) |
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 m_MixPlugins[iPlug].pMixPlugin->RestoreAllParameters(); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
255 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
256 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
257 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
258 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
259 if (m_nType) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
260 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
261 UINT maxpreamp = 0x10+(m_nChannels*8); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
262 if (maxpreamp > 100) maxpreamp = 100; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
263 if (m_nSongPreAmp > maxpreamp) m_nSongPreAmp = maxpreamp; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
264 return TRUE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
265 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
266 return FALSE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
267 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
268 |
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 BOOL CSoundFile::Destroy() |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
271 |
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 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
274 int i; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
275 for (i=0; i<MAX_PATTERNS; i++) if (Patterns[i]) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
276 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
277 FreePattern(Patterns[i]); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
278 Patterns[i] = NULL; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
279 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
280 m_nPatternNames = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
281 if (m_lpszPatternNames) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
282 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
283 delete m_lpszPatternNames; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
284 m_lpszPatternNames = NULL; |
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 if (m_lpszSongComments) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
287 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
288 delete m_lpszSongComments; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
289 m_lpszSongComments = NULL; |
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 for (i=1; i<MAX_SAMPLES; i++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
292 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
293 MODINSTRUMENT *pins = &Ins[i]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
294 if (pins->pSample) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
295 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
296 FreeSample(pins->pSample); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
297 pins->pSample = NULL; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
298 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
299 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
300 for (i=0; i<MAX_INSTRUMENTS; i++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
301 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
302 if (Headers[i]) |
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 delete Headers[i]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
305 Headers[i] = NULL; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
306 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
307 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
308 for (i=0; i<MAX_MIXPLUGINS; i++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
309 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
310 if ((m_MixPlugins[i].nPluginDataSize) && (m_MixPlugins[i].pPluginData)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
311 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
312 m_MixPlugins[i].nPluginDataSize = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
313 delete [] (signed char*)m_MixPlugins[i].pPluginData; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
314 m_MixPlugins[i].pPluginData = NULL; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
315 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
316 m_MixPlugins[i].pMixState = NULL; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
317 if (m_MixPlugins[i].pMixPlugin) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
318 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
319 m_MixPlugins[i].pMixPlugin->Release(); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
320 m_MixPlugins[i].pMixPlugin = NULL; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
321 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
322 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
323 m_nType = MOD_TYPE_NONE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
324 m_nChannels = m_nSamples = m_nInstruments = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
325 return TRUE; |
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 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
328 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
329 ////////////////////////////////////////////////////////////////////////// |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
330 // Memory Allocation |
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 MODCOMMAND *CSoundFile::AllocatePattern(UINT rows, UINT nchns) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
333 //------------------------------------------------------------ |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
334 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
335 MODCOMMAND *p = new MODCOMMAND[rows*nchns]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
336 if (p) memset(p, 0, rows*nchns*sizeof(MODCOMMAND)); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
337 return p; |
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 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
340 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
341 void CSoundFile::FreePattern(LPVOID pat) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
342 //-------------------------------------- |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
343 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
344 if (pat) delete [] (signed char*)pat; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
345 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
346 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
347 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
348 signed char* CSoundFile::AllocateSample(UINT nbytes) |
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 signed char * p = (signed char *)GlobalAllocPtr(GHND, (nbytes+39) & ~7); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
352 if (p) p += 16; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
353 return p; |
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 |
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 void CSoundFile::FreeSample(LPVOID p) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
358 //----------------------------------- |
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 if (p) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
361 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
362 GlobalFreePtr(((LPSTR)p)-16); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
363 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
364 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
365 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
366 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
367 ////////////////////////////////////////////////////////////////////////// |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
368 // Misc functions |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
369 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
370 void CSoundFile::ResetMidiCfg() |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
371 //----------------------------- |
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 memset(&m_MidiCfg, 0, sizeof(m_MidiCfg)); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
374 lstrcpy(&m_MidiCfg.szMidiGlb[MIDIOUT_START*32], "FF"); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
375 lstrcpy(&m_MidiCfg.szMidiGlb[MIDIOUT_STOP*32], "FC"); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
376 lstrcpy(&m_MidiCfg.szMidiGlb[MIDIOUT_NOTEON*32], "9c n v"); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
377 lstrcpy(&m_MidiCfg.szMidiGlb[MIDIOUT_NOTEOFF*32], "9c n 0"); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
378 lstrcpy(&m_MidiCfg.szMidiGlb[MIDIOUT_PROGRAM*32], "Cc p"); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
379 lstrcpy(&m_MidiCfg.szMidiSFXExt[0], "F0F000z"); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
380 for (int iz=0; iz<16; iz++) wsprintf(&m_MidiCfg.szMidiZXXExt[iz*32], "F0F001%02X", iz*8); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
381 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
382 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
383 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
384 UINT CSoundFile::GetNumChannels() const |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
385 //------------------------------------- |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
386 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
387 UINT n = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
388 for (UINT i=0; i<m_nChannels; i++) if (ChnSettings[i].nVolume) n++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
389 return n; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
390 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
391 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
392 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
393 UINT CSoundFile::GetSongComments(LPSTR s, UINT len, UINT linesize) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
394 //---------------------------------------------------------------- |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
395 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
396 LPCSTR p = m_lpszSongComments; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
397 if (!p) return 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
398 UINT i = 2, ln=0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
399 if ((len) && (s)) s[0] = '\x0D'; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
400 if ((len > 1) && (s)) s[1] = '\x0A'; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
401 while ((*p) && (i+2 < len)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
402 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
403 BYTE c = (BYTE)*p++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
404 if ((c == 0x0D) || ((c == ' ') && (ln >= linesize))) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
405 { if (s) { s[i++] = '\x0D'; s[i++] = '\x0A'; } else i+= 2; ln=0; } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
406 else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
407 if (c >= 0x20) { if (s) s[i++] = c; else i++; ln++; } |
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 (s) s[i] = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
410 return i; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
411 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
412 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
413 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
414 UINT CSoundFile::GetRawSongComments(LPSTR s, UINT len, UINT linesize) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
415 //------------------------------------------------------------------- |
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 LPCSTR p = m_lpszSongComments; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
418 if (!p) return 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
419 UINT i = 0, ln=0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
420 while ((*p) && (i < len-1)) |
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 BYTE c = (BYTE)*p++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
423 if ((c == 0x0D) || (c == 0x0A)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
424 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
425 if (ln) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
426 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
427 while (ln < linesize) { if (s) s[i] = ' '; i++; ln++; } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
428 ln = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
429 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
430 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
431 if ((c == ' ') && (!ln)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
432 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
433 UINT k=0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
434 while ((p[k]) && (p[k] >= ' ')) k++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
435 if (k <= linesize) |
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 if (s) s[i] = ' '; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
438 i++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
439 ln++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
440 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
441 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
442 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
443 if (s) s[i] = c; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
444 i++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
445 ln++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
446 if (ln == linesize) ln = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
447 } |
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 if (ln) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
450 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
451 while ((ln < linesize) && (i < len)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
452 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
453 if (s) s[i] = ' '; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
454 i++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
455 ln++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
456 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
457 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
458 if (s) s[i] = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
459 return i; |
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 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
463 BOOL CSoundFile::SetWaveConfig(UINT nRate,UINT nBits,UINT nChannels,BOOL bMMX) |
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 BOOL bReset = FALSE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
467 DWORD d = gdwSoundSetup & ~SNDMIX_ENABLEMMX; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
468 if (bMMX) d |= SNDMIX_ENABLEMMX; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
469 if ((gdwMixingFreq != nRate) || (gnBitsPerSample != nBits) || (gnChannels != nChannels) || (d != gdwSoundSetup)) bReset = TRUE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
470 gnChannels = nChannels; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
471 gdwSoundSetup = d; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
472 gdwMixingFreq = nRate; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
473 gnBitsPerSample = nBits; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
474 InitPlayer(bReset); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
475 return TRUE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
476 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
477 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
478 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
479 BOOL CSoundFile::SetResamplingMode(UINT nMode) |
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 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
482 DWORD d = gdwSoundSetup & ~(SNDMIX_NORESAMPLING|SNDMIX_HQRESAMPLER|SNDMIX_ULTRAHQSRCMODE); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
483 switch(nMode) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
484 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
485 case SRCMODE_NEAREST: d |= SNDMIX_NORESAMPLING; break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
486 case SRCMODE_LINEAR: break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
487 case SRCMODE_SPLINE: d |= SNDMIX_HQRESAMPLER; break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
488 case SRCMODE_POLYPHASE: d |= (SNDMIX_HQRESAMPLER|SNDMIX_ULTRAHQSRCMODE); break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
489 default: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
490 return FALSE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
491 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
492 gdwSoundSetup = d; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
493 return TRUE; |
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 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
496 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
497 BOOL CSoundFile::SetMasterVolume(UINT nVol, BOOL bAdjustAGC) |
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 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
500 if (nVol < 1) nVol = 1; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
501 if (nVol > 0x200) nVol = 0x200; // x4 maximum |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
502 if ((nVol < m_nMasterVolume) && (nVol) && (gdwSoundSetup & SNDMIX_AGC) && (bAdjustAGC)) |
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 gnAGC = gnAGC * m_nMasterVolume / nVol; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
505 if (gnAGC > AGC_UNITY) gnAGC = AGC_UNITY; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
506 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
507 m_nMasterVolume = nVol; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
508 return TRUE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
509 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
510 |
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 void CSoundFile::SetAGC(BOOL b) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
513 //----------------------------- |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
514 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
515 if (b) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
516 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
517 if (!(gdwSoundSetup & SNDMIX_AGC)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
518 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
519 gdwSoundSetup |= SNDMIX_AGC; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
520 gnAGC = AGC_UNITY; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
521 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
522 } else gdwSoundSetup &= ~SNDMIX_AGC; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
523 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
524 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
525 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
526 UINT CSoundFile::GetNumPatterns() const |
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 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
529 UINT i = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
530 while ((i < MAX_ORDERS) && (Order[i] < 0xFF)) i++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
531 return i; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
532 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
533 |
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 CSoundFile::GetNumInstruments() const |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
536 //---------------------------------------- |
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 UINT n=0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
539 for (UINT i=0; i<MAX_INSTRUMENTS; i++) if (Ins[i].pSample) n++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
540 return n; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
541 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
542 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
543 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
544 UINT CSoundFile::GetMaxPosition() const |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
545 //------------------------------------- |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
546 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
547 UINT max = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
548 UINT i = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
549 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
550 while ((i < MAX_ORDERS) && (Order[i] != 0xFF)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
551 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
552 if (Order[i] < MAX_PATTERNS) max += PatternSize[Order[i]]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
553 i++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
554 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
555 return max; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
556 } |
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 UINT CSoundFile::GetCurrentPos() const |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
560 //------------------------------------ |
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 pos = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
563 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
564 for (UINT i=0; i<m_nCurrentPattern; i++) if (Order[i] < MAX_PATTERNS) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
565 pos += PatternSize[Order[i]]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
566 return pos + m_nRow; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
567 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
568 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
569 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
570 void CSoundFile::SetCurrentPos(UINT nPos) |
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 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
573 UINT i, nPattern; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
574 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
575 for (i=0; i<MAX_CHANNELS; i++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
576 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
577 Chn[i].nNote = Chn[i].nNewNote = Chn[i].nNewIns = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
578 Chn[i].pInstrument = NULL; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
579 Chn[i].pHeader = NULL; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
580 Chn[i].nPortamentoDest = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
581 Chn[i].nCommand = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
582 Chn[i].nPatternLoopCount = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
583 Chn[i].nPatternLoop = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
584 Chn[i].nFadeOutVol = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
585 Chn[i].dwFlags |= CHN_KEYOFF|CHN_NOTEFADE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
586 Chn[i].nTremorCount = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
587 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
588 if (!nPos) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
589 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
590 for (i=0; i<MAX_CHANNELS; i++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
591 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
592 Chn[i].nPeriod = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
593 Chn[i].nPos = Chn[i].nLength = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
594 Chn[i].nLoopStart = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
595 Chn[i].nLoopEnd = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
596 Chn[i].nROfs = Chn[i].nLOfs = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
597 Chn[i].pSample = NULL; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
598 Chn[i].pInstrument = NULL; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
599 Chn[i].pHeader = NULL; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
600 Chn[i].nCutOff = 0x7F; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
601 Chn[i].nResonance = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
602 Chn[i].nLeftVol = Chn[i].nRightVol = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
603 Chn[i].nNewLeftVol = Chn[i].nNewRightVol = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
604 Chn[i].nLeftRamp = Chn[i].nRightRamp = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
605 Chn[i].nVolume = 256; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
606 if (i < MAX_BASECHANNELS) |
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 Chn[i].dwFlags = ChnSettings[i].dwFlags; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
609 Chn[i].nPan = ChnSettings[i].nPan; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
610 Chn[i].nGlobalVol = ChnSettings[i].nVolume; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
611 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
612 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
613 Chn[i].dwFlags = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
614 Chn[i].nPan = 128; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
615 Chn[i].nGlobalVol = 64; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
616 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
617 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
618 m_nGlobalVolume = m_nDefaultGlobalVolume; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
619 m_nMusicSpeed = m_nDefaultSpeed; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
620 m_nMusicTempo = m_nDefaultTempo; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
621 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
622 m_dwSongFlags &= ~(SONG_PATTERNLOOP|SONG_CPUVERYHIGH|SONG_FADINGSONG|SONG_ENDREACHED|SONG_GLOBALFADE); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
623 for (nPattern = 0; nPattern < MAX_ORDERS; nPattern++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
624 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
625 UINT ord = Order[nPattern]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
626 if (ord == 0xFE) continue; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
627 if (ord == 0xFF) break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
628 if (ord < MAX_PATTERNS) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
629 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
630 if (nPos < (UINT)PatternSize[ord]) break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
631 nPos -= PatternSize[ord]; |
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 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
634 // Buggy position ? |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
635 if ((nPattern >= MAX_ORDERS) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
636 || (Order[nPattern] >= MAX_PATTERNS) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
637 || (nPos >= PatternSize[Order[nPattern]])) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
638 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
639 nPos = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
640 nPattern = 0; |
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 UINT nRow = nPos; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
643 if ((nRow) && (Order[nPattern] < MAX_PATTERNS)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
644 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
645 MODCOMMAND *p = Patterns[Order[nPattern]]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
646 if ((p) && (nRow < PatternSize[Order[nPattern]])) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
647 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
648 BOOL bOk = FALSE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
649 while ((!bOk) && (nRow > 0)) |
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 UINT n = nRow * m_nChannels; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
652 for (UINT k=0; k<m_nChannels; k++, n++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
653 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
654 if (p[n].note) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
655 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
656 bOk = TRUE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
657 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
658 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
659 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
660 if (!bOk) nRow--; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
661 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
662 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
663 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
664 m_nNextPattern = nPattern; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
665 m_nNextRow = nRow; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
666 m_nTickCount = m_nMusicSpeed; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
667 m_nBufferCount = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
668 m_nPatternDelay = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
669 m_nFrameDelay = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
670 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
671 |
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 void CSoundFile::SetCurrentOrder(UINT nPos) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
674 //----------------------------------------- |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
675 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
676 while ((nPos < MAX_ORDERS) && (Order[nPos] == 0xFE)) nPos++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
677 if ((nPos >= MAX_ORDERS) || (Order[nPos] >= MAX_PATTERNS)) return; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
678 for (UINT j=0; j<MAX_CHANNELS; j++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
679 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
680 Chn[j].nPeriod = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
681 Chn[j].nNote = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
682 Chn[j].nPortamentoDest = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
683 Chn[j].nCommand = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
684 Chn[j].nPatternLoopCount = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
685 Chn[j].nPatternLoop = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
686 Chn[j].nTremorCount = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
687 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
688 if (!nPos) |
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 SetCurrentPos(0); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
691 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
692 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
693 m_nNextPattern = nPos; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
694 m_nRow = m_nNextRow = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
695 m_nPattern = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
696 m_nTickCount = m_nMusicSpeed; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
697 m_nBufferCount = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
698 m_nTotalCount = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
699 m_nPatternDelay = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
700 m_nFrameDelay = 0; |
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 m_dwSongFlags &= ~(SONG_PATTERNLOOP|SONG_CPUVERYHIGH|SONG_FADINGSONG|SONG_ENDREACHED|SONG_GLOBALFADE); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
703 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
704 |
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 void CSoundFile::ResetChannels() |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
707 //------------------------------ |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
708 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
709 m_dwSongFlags &= ~(SONG_CPUVERYHIGH|SONG_FADINGSONG|SONG_ENDREACHED|SONG_GLOBALFADE); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
710 m_nBufferCount = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
711 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
|
712 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
713 Chn[i].nROfs = Chn[i].nLOfs = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
714 } |
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 |
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 void CSoundFile::LoopPattern(int nPat, int nRow) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
719 //---------------------------------------------- |
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 if ((nPat < 0) || (nPat >= MAX_PATTERNS) || (!Patterns[nPat])) |
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 m_dwSongFlags &= ~SONG_PATTERNLOOP; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
724 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
725 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
726 if ((nRow < 0) || (nRow >= PatternSize[nPat])) nRow = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
727 m_nPattern = nPat; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
728 m_nRow = m_nNextRow = nRow; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
729 m_nTickCount = m_nMusicSpeed; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
730 m_nPatternDelay = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
731 m_nFrameDelay = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
732 m_nBufferCount = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
733 m_dwSongFlags |= SONG_PATTERNLOOP; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
734 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
735 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
736 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
737 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
738 UINT CSoundFile::GetBestSaveFormat() const |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
739 //---------------------------------------- |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
740 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
741 if ((!m_nSamples) || (!m_nChannels)) return MOD_TYPE_NONE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
742 if (!m_nType) return MOD_TYPE_NONE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
743 if (m_nType & (MOD_TYPE_MOD|MOD_TYPE_OKT)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
744 return MOD_TYPE_MOD; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
745 if (m_nType & (MOD_TYPE_S3M|MOD_TYPE_STM|MOD_TYPE_ULT|MOD_TYPE_FAR|MOD_TYPE_PTM)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
746 return MOD_TYPE_S3M; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
747 if (m_nType & (MOD_TYPE_XM|MOD_TYPE_MED|MOD_TYPE_MTM|MOD_TYPE_MT2)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
748 return MOD_TYPE_XM; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
749 return MOD_TYPE_IT; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
750 } |
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 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
753 UINT CSoundFile::GetSaveFormats() const |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
754 //------------------------------------- |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
755 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
756 UINT n = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
757 if ((!m_nSamples) || (!m_nChannels) || (m_nType == MOD_TYPE_NONE)) return 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
758 switch(m_nType) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
759 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
760 case MOD_TYPE_MOD: n = MOD_TYPE_MOD; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
761 case MOD_TYPE_S3M: n = MOD_TYPE_S3M; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
762 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
763 n |= MOD_TYPE_XM | MOD_TYPE_IT; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
764 if (!m_nInstruments) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
765 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
766 if (m_nSamples < 32) n |= MOD_TYPE_MOD; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
767 n |= MOD_TYPE_S3M; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
768 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
769 return n; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
770 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
771 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
772 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
773 UINT CSoundFile::GetSampleName(UINT nSample,LPSTR s) const |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
774 //-------------------------------------------------------- |
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 char sztmp[40] = ""; // changed from CHAR |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
777 memcpy(sztmp, m_szNames[nSample],32); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
778 sztmp[31] = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
779 if (s) strcpy(s, sztmp); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
780 return strlen(sztmp); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
781 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
782 |
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 UINT CSoundFile::GetInstrumentName(UINT nInstr,LPSTR s) const |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
785 //----------------------------------------------------------- |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
786 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
787 char sztmp[40] = ""; // changed from CHAR |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
788 if ((nInstr >= MAX_INSTRUMENTS) || (!Headers[nInstr])) |
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 if (s) *s = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
791 return 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
792 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
793 INSTRUMENTHEADER *penv = Headers[nInstr]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
794 memcpy(sztmp, penv->name, 32); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
795 sztmp[31] = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
796 if (s) strcpy(s, sztmp); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
797 return strlen(sztmp); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
798 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
799 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
800 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
801 #ifndef NO_PACKING |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
802 UINT CSoundFile::PackSample(int &sample, int next) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
803 //------------------------------------------------ |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
804 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
805 UINT i = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
806 int delta = next - sample; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
807 if (delta >= 0) |
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 for (i=0; i<7; i++) if (delta <= (int)CompressionTable[i+1]) break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
810 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
811 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
812 for (i=8; i<15; i++) if (delta >= (int)CompressionTable[i+1]) break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
813 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
814 sample += (int)CompressionTable[i]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
815 return i; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
816 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
817 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
818 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
819 BOOL CSoundFile::CanPackSample(LPSTR pSample, UINT nLen, UINT nPacking, BYTE *result) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
820 //----------------------------------------------------------------------------------- |
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 int pos, old, oldpos, besttable = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
823 DWORD dwErr, dwTotal, dwResult; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
824 int i,j; |
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 if (result) *result = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
827 if ((!pSample) || (nLen < 1024)) return FALSE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
828 // Try packing with different tables |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
829 dwResult = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
830 for (j=1; j<MAX_PACK_TABLES; j++) |
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 memcpy(CompressionTable, UnpackTable[j], 16); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
833 dwErr = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
834 dwTotal = 1; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
835 old = pos = oldpos = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
836 for (i=0; i<(int)nLen; i++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
837 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
838 int s = (int)pSample[i]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
839 PackSample(pos, s); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
840 dwErr += abs(pos - oldpos); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
841 dwTotal += abs(s - old); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
842 old = s; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
843 oldpos = pos; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
844 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
845 dwErr = _muldiv(dwErr, 100, dwTotal); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
846 if (dwErr >= dwResult) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
847 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
848 dwResult = dwErr; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
849 besttable = j; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
850 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
851 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
852 memcpy(CompressionTable, UnpackTable[besttable], 16); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
853 if (result) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
854 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
855 if (dwResult > 100) *result = 100; else *result = (BYTE)dwResult; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
856 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
857 return (dwResult >= nPacking) ? TRUE : FALSE; |
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 #endif // NO_PACKING |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
860 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
861 #ifndef MODPLUG_NO_FILESAVE |
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 UINT CSoundFile::WriteSample(FILE *f, MODINSTRUMENT *pins, UINT nFlags, UINT nMaxLen) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
864 //----------------------------------------------------------------------------------- |
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 UINT len = 0, bufcount; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
867 signed char buffer[4096]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
868 signed char *pSample = (signed char *)pins->pSample; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
869 UINT nLen = pins->nLength; |
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 if ((nMaxLen) && (nLen > nMaxLen)) nLen = nMaxLen; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
872 if ((!pSample) || (f == NULL) || (!nLen)) return 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
873 switch(nFlags) |
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 #ifndef NO_PACKING |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
876 // 3: 4-bit ADPCM data |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
877 case RS_ADPCM4: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
878 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
879 int pos; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
880 len = (nLen + 1) / 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
881 fwrite(CompressionTable, 16, 1, f); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
882 bufcount = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
883 pos = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
884 for (UINT j=0; j<len; j++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
885 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
886 BYTE b; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
887 // Sample #1 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
888 b = PackSample(pos, (int)pSample[j*2]); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
889 // Sample #2 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
890 b |= PackSample(pos, (int)pSample[j*2+1]) << 4; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
891 buffer[bufcount++] = (signed char)b; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
892 if (bufcount >= sizeof(buffer)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
893 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
894 fwrite(buffer, 1, bufcount, f); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
895 bufcount = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
896 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
897 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
898 if (bufcount) fwrite(buffer, 1, bufcount, f); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
899 len += 16; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
900 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
901 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
902 #endif // NO_PACKING |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
903 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
904 // 16-bit samples |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
905 case RS_PCM16U: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
906 case RS_PCM16D: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
907 case RS_PCM16S: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
908 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
909 short int *p = (short int *)pSample; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
910 int s_old = 0, s_ofs; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
911 len = nLen * 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
912 bufcount = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
913 s_ofs = (nFlags == RS_PCM16U) ? 0x8000 : 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
914 for (UINT j=0; j<nLen; j++) |
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 int s_new = *p; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
917 p++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
918 if (pins->uFlags & CHN_STEREO) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
919 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
920 s_new = (s_new + (*p) + 1) >> 1; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
921 p++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
922 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
923 if (nFlags == RS_PCM16D) |
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 short temp = bswapLE16((short)(s_new - s_old)); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
926 *((short *)(&buffer[bufcount])) = temp; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
927 s_old = s_new; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
928 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
929 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
930 short temp = bswapLE16((short)(s_new + s_ofs)); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
931 *((short *)(&buffer[bufcount])) = temp; |
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 bufcount += 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
934 if (bufcount >= sizeof(buffer) - 1) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
935 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
936 fwrite(buffer, 1, bufcount, f); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
937 bufcount = 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 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
940 if (bufcount) fwrite(buffer, 1, bufcount, f); |
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 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
943 |
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 // 8-bit Stereo samples (not interleaved) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
946 case RS_STPCM8S: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
947 case RS_STPCM8U: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
948 case RS_STPCM8D: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
949 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
950 int s_ofs = (nFlags == RS_STPCM8U) ? 0x80 : 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
951 for (UINT iCh=0; iCh<2; iCh++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
952 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
953 signed char *p = pSample + iCh; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
954 int s_old = 0; |
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 bufcount = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
957 for (UINT j=0; j<nLen; j++) |
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 int s_new = *p; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
960 p += 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
961 if (nFlags == RS_STPCM8D) |
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 buffer[bufcount++] = (signed char)(s_new - s_old); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
964 s_old = s_new; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
965 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
966 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
967 buffer[bufcount++] = (signed char)(s_new + s_ofs); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
968 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
969 if (bufcount >= sizeof(buffer)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
970 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
971 fwrite(buffer, 1, bufcount, f); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
972 bufcount = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
973 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
974 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
975 if (bufcount) fwrite(buffer, 1, bufcount, f); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
976 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
977 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
978 len = nLen * 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
979 break; |
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 // 16-bit Stereo samples (not interleaved) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
982 case RS_STPCM16S: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
983 case RS_STPCM16U: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
984 case RS_STPCM16D: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
985 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
986 int s_ofs = (nFlags == RS_STPCM16U) ? 0x8000 : 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
987 for (UINT iCh=0; iCh<2; iCh++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
988 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
989 signed short *p = ((signed short *)pSample) + iCh; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
990 int s_old = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
991 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
992 bufcount = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
993 for (UINT j=0; j<nLen; j++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
994 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
995 int s_new = *p; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
996 p += 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
997 if (nFlags == RS_STPCM16D) |
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 short temp = bswapLE16((short)(s_new - s_old)); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1000 *((short *)(&buffer[bufcount])) = temp; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1001 s_old = s_new; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1002 } else |
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 short temp = bswapLE16((short)(s_new - s_ofs)); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1005 *((short *)(&buffer[bufcount])) = temp; |
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 bufcount += 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1008 if (bufcount >= sizeof(buffer)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1009 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1010 fwrite(buffer, 1, bufcount, f); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1011 bufcount = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1012 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1013 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1014 if (bufcount) fwrite(buffer, 1, bufcount, f); |
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 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1017 len = nLen*4; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1018 break; |
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 // Stereo signed interleaved |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1021 case RS_STIPCM8S: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1022 case RS_STIPCM16S: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1023 len = nLen * 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1024 if (nFlags == RS_STIPCM16S) len *= 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1025 fwrite(pSample, 1, len, f); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1026 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1027 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1028 // Default: assume 8-bit PCM data |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1029 default: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1030 len = nLen; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1031 bufcount = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1032 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1033 signed char *p = pSample; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1034 int sinc = (pins->uFlags & CHN_16BIT) ? 2 : 1; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1035 int s_old = 0, s_ofs = (nFlags == RS_PCM8U) ? 0x80 : 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1036 if (pins->uFlags & CHN_16BIT) p++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1037 for (UINT j=0; j<len; j++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1038 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1039 int s_new = (signed char)(*p); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1040 p += sinc; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1041 if (pins->uFlags & CHN_STEREO) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1042 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1043 s_new = (s_new + ((int)*p) + 1) >> 1; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1044 p += sinc; |
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 if (nFlags == RS_PCM8D) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1047 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1048 buffer[bufcount++] = (signed char)(s_new - s_old); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1049 s_old = s_new; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1050 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1051 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1052 buffer[bufcount++] = (signed char)(s_new + s_ofs); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1053 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1054 if (bufcount >= sizeof(buffer)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1055 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1056 fwrite(buffer, 1, bufcount, f); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1057 bufcount = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1058 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1059 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1060 if (bufcount) fwrite(buffer, 1, bufcount, f); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1061 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1062 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1063 return len; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1064 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1065 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1066 #endif // MODPLUG_NO_FILESAVE |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1067 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1068 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1069 // Flags: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1070 // 0 = signed 8-bit PCM data (default) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1071 // 1 = unsigned 8-bit PCM data |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1072 // 2 = 8-bit ADPCM data with linear table |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1073 // 3 = 4-bit ADPCM data |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1074 // 4 = 16-bit ADPCM data with linear table |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1075 // 5 = signed 16-bit PCM data |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1076 // 6 = unsigned 16-bit PCM data |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1077 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1078 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1079 UINT CSoundFile::ReadSample(MODINSTRUMENT *pIns, UINT nFlags, LPCSTR lpMemFile, DWORD dwMemLength) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1080 //------------------------------------------------------------------------------------------------ |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1081 { |
143
e8f34254bc18
[svn] - overflow fixes for modplug (via Stanislav Brabec @ novell/suse).
nenolod
parents:
136
diff
changeset
|
1082 UINT len = 0, mem; |
136
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1083 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1084 if ((!pIns) || (pIns->nLength < 4) || (!lpMemFile)) return 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1085 if (pIns->nLength > MAX_SAMPLE_LENGTH) pIns->nLength = MAX_SAMPLE_LENGTH; |
143
e8f34254bc18
[svn] - overflow fixes for modplug (via Stanislav Brabec @ novell/suse).
nenolod
parents:
136
diff
changeset
|
1086 mem = pIns->nLength+6; |
136
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1087 pIns->uFlags &= ~(CHN_16BIT|CHN_STEREO); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1088 if (nFlags & RSF_16BIT) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1089 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1090 mem *= 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1091 pIns->uFlags |= CHN_16BIT; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1092 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1093 if (nFlags & RSF_STEREO) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1094 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1095 mem *= 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1096 pIns->uFlags |= CHN_STEREO; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1097 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1098 if ((pIns->pSample = AllocateSample(mem)) == NULL) |
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 pIns->nLength = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1101 return 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1102 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1103 switch(nFlags) |
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 // 1: 8-bit unsigned PCM data |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1106 case RS_PCM8U: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1107 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1108 len = pIns->nLength; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1109 if (len > dwMemLength) len = pIns->nLength = dwMemLength; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1110 signed char *pSample = pIns->pSample; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1111 for (UINT j=0; j<len; j++) pSample[j] = (signed char)(lpMemFile[j] - 0x80); |
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 break; |
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 // 2: 8-bit ADPCM data with linear table |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1116 case RS_PCM8D: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1117 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1118 len = pIns->nLength; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1119 if (len > dwMemLength) break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1120 signed char *pSample = pIns->pSample; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1121 const signed char *p = (const signed char *)lpMemFile; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1122 int delta = 0; |
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 for (UINT j=0; j<len; j++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1125 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1126 delta += p[j]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1127 *pSample++ = (signed char)delta; |
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 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1130 break; |
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 // 3: 4-bit ADPCM data |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1133 case RS_ADPCM4: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1134 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1135 len = (pIns->nLength + 1) / 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1136 if (len > dwMemLength - 16) break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1137 memcpy(CompressionTable, lpMemFile, 16); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1138 lpMemFile += 16; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1139 signed char *pSample = pIns->pSample; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1140 signed char delta = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1141 for (UINT j=0; j<len; j++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1142 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1143 BYTE b0 = (BYTE)lpMemFile[j]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1144 BYTE b1 = (BYTE)(lpMemFile[j] >> 4); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1145 delta = (signed char)GetDeltaValue((int)delta, b0); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1146 pSample[0] = delta; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1147 delta = (signed char)GetDeltaValue((int)delta, b1); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1148 pSample[1] = delta; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1149 pSample += 2; |
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 len += 16; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1152 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1153 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1154 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1155 // 4: 16-bit ADPCM data with linear table |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1156 case RS_PCM16D: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1157 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1158 len = pIns->nLength * 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1159 if (len > dwMemLength) break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1160 short int *pSample = (short int *)pIns->pSample; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1161 short int *p = (short int *)lpMemFile; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1162 int delta16 = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1163 for (UINT j=0; j<len; j+=2) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1164 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1165 delta16 += bswapLE16(*p++); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1166 *pSample++ = (short int)delta16; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1167 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1168 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1169 break; |
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 // 5: 16-bit signed PCM data |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1172 case RS_PCM16S: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1173 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1174 len = pIns->nLength * 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1175 if (len <= dwMemLength) memcpy(pIns->pSample, lpMemFile, len); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1176 short int *pSample = (short int *)pIns->pSample; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1177 for (UINT j=0; j<len; j+=2) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1178 { |
963 | 1179 *pSample = bswapLE16(*pSample); |
1180 ++pSample; | |
136
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1181 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1182 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1183 break; |
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 // 16-bit signed mono PCM motorola byte order |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1186 case RS_PCM16M: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1187 len = pIns->nLength * 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1188 if (len > dwMemLength) len = dwMemLength & ~1; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1189 if (len > 1) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1190 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1191 signed char *pSample = (signed char *)pIns->pSample; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1192 signed char *pSrc = (signed char *)lpMemFile; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1193 for (UINT j=0; j<len; j+=2) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1194 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1195 // pSample[j] = pSrc[j+1]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1196 // pSample[j+1] = pSrc[j]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1197 *((unsigned short *)(pSample+j)) = bswapBE16(*((unsigned short *)(pSrc+j))); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1198 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1199 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1200 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1201 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1202 // 6: 16-bit unsigned PCM data |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1203 case RS_PCM16U: |
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 len = pIns->nLength * 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1206 if (len > dwMemLength) break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1207 short int *pSample = (short int *)pIns->pSample; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1208 short int *pSrc = (short int *)lpMemFile; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1209 for (UINT j=0; j<len; j+=2) *pSample++ = bswapLE16(*(pSrc++)) - 0x8000; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1210 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1211 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1212 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1213 // 16-bit signed stereo big endian |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1214 case RS_STPCM16M: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1215 len = pIns->nLength * 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1216 if (len*2 <= dwMemLength) |
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 signed char *pSample = (signed char *)pIns->pSample; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1219 signed char *pSrc = (signed char *)lpMemFile; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1220 for (UINT j=0; j<len; j+=2) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1221 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1222 // pSample[j*2] = pSrc[j+1]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1223 // pSample[j*2+1] = pSrc[j]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1224 // pSample[j*2+2] = pSrc[j+1+len]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1225 // pSample[j*2+3] = pSrc[j+len]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1226 *((unsigned short *)(pSample+j*2)) = bswapBE16(*((unsigned short *)(pSrc+j))); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1227 *((unsigned short *)(pSample+j*2+2)) = bswapBE16(*((unsigned short *)(pSrc+j+len))); |
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 len *= 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1230 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1231 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1232 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1233 // 8-bit stereo samples |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1234 case RS_STPCM8S: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1235 case RS_STPCM8U: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1236 case RS_STPCM8D: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1237 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1238 int iadd_l = 0, iadd_r = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1239 if (nFlags == RS_STPCM8U) { iadd_l = iadd_r = -128; } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1240 len = pIns->nLength; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1241 signed char *psrc = (signed char *)lpMemFile; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1242 signed char *pSample = (signed char *)pIns->pSample; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1243 if (len*2 > dwMemLength) break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1244 for (UINT j=0; j<len; j++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1245 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1246 pSample[j*2] = (signed char)(psrc[0] + iadd_l); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1247 pSample[j*2+1] = (signed char)(psrc[len] + iadd_r); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1248 psrc++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1249 if (nFlags == RS_STPCM8D) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1250 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1251 iadd_l = pSample[j*2]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1252 iadd_r = pSample[j*2+1]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1253 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1254 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1255 len *= 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1256 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1257 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1258 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1259 // 16-bit stereo samples |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1260 case RS_STPCM16S: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1261 case RS_STPCM16U: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1262 case RS_STPCM16D: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1263 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1264 int iadd_l = 0, iadd_r = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1265 if (nFlags == RS_STPCM16U) { iadd_l = iadd_r = -0x8000; } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1266 len = pIns->nLength; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1267 short int *psrc = (short int *)lpMemFile; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1268 short int *pSample = (short int *)pIns->pSample; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1269 if (len*4 > dwMemLength) break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1270 for (UINT j=0; j<len; j++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1271 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1272 pSample[j*2] = (short int) (bswapLE16(psrc[0]) + iadd_l); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1273 pSample[j*2+1] = (short int) (bswapLE16(psrc[len]) + iadd_r); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1274 psrc++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1275 if (nFlags == RS_STPCM16D) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1276 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1277 iadd_l = pSample[j*2]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1278 iadd_r = pSample[j*2+1]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1279 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1280 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1281 len *= 4; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1282 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1283 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1284 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1285 // IT 2.14 compressed samples |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1286 case RS_IT2148: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1287 case RS_IT21416: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1288 case RS_IT2158: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1289 case RS_IT21516: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1290 len = dwMemLength; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1291 if (len < 4) break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1292 if ((nFlags == RS_IT2148) || (nFlags == RS_IT2158)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1293 ITUnpack8Bit(pIns->pSample, pIns->nLength, (LPBYTE)lpMemFile, dwMemLength, (nFlags == RS_IT2158)); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1294 else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1295 ITUnpack16Bit(pIns->pSample, pIns->nLength, (LPBYTE)lpMemFile, dwMemLength, (nFlags == RS_IT21516)); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1296 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1297 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1298 #ifndef MODPLUG_BASIC_SUPPORT |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1299 #ifndef MODPLUG_FASTSOUNDLIB |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1300 // 8-bit interleaved stereo samples |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1301 case RS_STIPCM8S: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1302 case RS_STIPCM8U: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1303 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1304 int iadd = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1305 if (nFlags == RS_STIPCM8U) { iadd = -0x80; } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1306 len = pIns->nLength; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1307 if (len*2 > dwMemLength) len = dwMemLength >> 1; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1308 LPBYTE psrc = (LPBYTE)lpMemFile; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1309 LPBYTE pSample = (LPBYTE)pIns->pSample; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1310 for (UINT j=0; j<len; j++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1311 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1312 pSample[j*2] = (signed char)(psrc[0] + iadd); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1313 pSample[j*2+1] = (signed char)(psrc[1] + iadd); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1314 psrc+=2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1315 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1316 len *= 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1317 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1318 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1319 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1320 // 16-bit interleaved stereo samples |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1321 case RS_STIPCM16S: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1322 case RS_STIPCM16U: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1323 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1324 int iadd = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1325 if (nFlags == RS_STIPCM16U) iadd = -32768; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1326 len = pIns->nLength; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1327 if (len*4 > dwMemLength) len = dwMemLength >> 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1328 short int *psrc = (short int *)lpMemFile; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1329 short int *pSample = (short int *)pIns->pSample; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1330 for (UINT j=0; j<len; j++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1331 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1332 pSample[j*2] = (short int)(bswapLE16(psrc[0]) + iadd); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1333 pSample[j*2+1] = (short int)(bswapLE16(psrc[1]) + iadd); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1334 psrc += 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1335 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1336 len *= 4; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1337 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1338 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1339 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1340 // AMS compressed samples |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1341 case RS_AMS8: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1342 case RS_AMS16: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1343 len = 9; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1344 if (dwMemLength > 9) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1345 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1346 const char *psrc = lpMemFile; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1347 char packcharacter = lpMemFile[8], *pdest = (char *)pIns->pSample; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1348 len += bswapLE32(*((LPDWORD)(lpMemFile+4))); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1349 if (len > dwMemLength) len = dwMemLength; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1350 UINT dmax = pIns->nLength; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1351 if (pIns->uFlags & CHN_16BIT) dmax <<= 1; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1352 AMSUnpack(psrc+9, len-9, pdest, dmax, packcharacter); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1353 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1354 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1355 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1356 // PTM 8bit delta to 16-bit sample |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1357 case RS_PTM8DTO16: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1358 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1359 len = pIns->nLength * 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1360 if (len > dwMemLength) break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1361 signed char *pSample = (signed char *)pIns->pSample; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1362 signed char delta8 = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1363 for (UINT j=0; j<len; j++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1364 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1365 delta8 += lpMemFile[j]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1366 *pSample++ = delta8; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1367 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1368 WORD *pSampleW = (WORD *)pIns->pSample; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1369 for (UINT j=0; j<len; j+=2) // swaparoni! |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1370 { |
963 | 1371 *pSampleW = bswapLE16(*pSampleW); |
1372 ++pSampleW; | |
136
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1373 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1374 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1375 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1376 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1377 // Huffman MDL compressed samples |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1378 case RS_MDL8: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1379 case RS_MDL16: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1380 len = dwMemLength; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1381 if (len >= 4) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1382 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1383 LPBYTE pSample = (LPBYTE)pIns->pSample; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1384 LPBYTE ibuf = (LPBYTE)lpMemFile; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1385 DWORD bitbuf = bswapLE32(*((DWORD *)ibuf)); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1386 UINT bitnum = 32; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1387 BYTE dlt = 0, lowbyte = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1388 ibuf += 4; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1389 for (UINT j=0; j<pIns->nLength; j++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1390 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1391 BYTE hibyte; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1392 BYTE sign; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1393 if (nFlags == RS_MDL16) lowbyte = (BYTE)MDLReadBits(bitbuf, bitnum, ibuf, 8); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1394 sign = (BYTE)MDLReadBits(bitbuf, bitnum, ibuf, 1); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1395 if (MDLReadBits(bitbuf, bitnum, ibuf, 1)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1396 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1397 hibyte = (BYTE)MDLReadBits(bitbuf, bitnum, ibuf, 3); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1398 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1399 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1400 hibyte = 8; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1401 while (!MDLReadBits(bitbuf, bitnum, ibuf, 1)) hibyte += 0x10; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1402 hibyte += MDLReadBits(bitbuf, bitnum, ibuf, 4); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1403 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1404 if (sign) hibyte = ~hibyte; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1405 dlt += hibyte; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1406 if (nFlags != RS_MDL16) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1407 pSample[j] = dlt; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1408 else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1409 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1410 pSample[j<<1] = lowbyte; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1411 pSample[(j<<1)+1] = dlt; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1412 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1413 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1414 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1415 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1416 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1417 case RS_DMF8: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1418 case RS_DMF16: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1419 len = dwMemLength; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1420 if (len >= 4) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1421 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1422 UINT maxlen = pIns->nLength; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1423 if (pIns->uFlags & CHN_16BIT) maxlen <<= 1; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1424 LPBYTE ibuf = (LPBYTE)lpMemFile, ibufmax = (LPBYTE)(lpMemFile+dwMemLength); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1425 len = DMFUnpack((LPBYTE)pIns->pSample, ibuf, ibufmax, maxlen); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1426 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1427 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1428 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1429 #ifdef MODPLUG_TRACKER |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1430 // PCM 24-bit signed -> load sample, and normalize it to 16-bit |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1431 case RS_PCM24S: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1432 case RS_PCM32S: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1433 len = pIns->nLength * 3; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1434 if (nFlags == RS_PCM32S) len += pIns->nLength; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1435 if (len > dwMemLength) break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1436 if (len > 4*8) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1437 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1438 UINT slsize = (nFlags == RS_PCM32S) ? 4 : 3; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1439 LPBYTE pSrc = (LPBYTE)lpMemFile; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1440 LONG max = 255; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1441 if (nFlags == RS_PCM32S) pSrc++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1442 for (UINT j=0; j<len; j+=slsize) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1443 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1444 LONG l = ((((pSrc[j+2] << 8) + pSrc[j+1]) << 8) + pSrc[j]) << 8; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1445 l /= 256; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1446 if (l > max) max = l; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1447 if (-l > max) max = -l; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1448 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1449 max = (max / 128) + 1; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1450 signed short *pDest = (signed short *)pIns->pSample; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1451 for (UINT k=0; k<len; k+=slsize) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1452 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1453 LONG l = ((((pSrc[k+2] << 8) + pSrc[k+1]) << 8) + pSrc[k]) << 8; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1454 *pDest++ = (signed short)(l / max); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1455 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1456 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1457 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1458 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1459 // Stereo PCM 24-bit signed -> load sample, and normalize it to 16-bit |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1460 case RS_STIPCM24S: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1461 case RS_STIPCM32S: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1462 len = pIns->nLength * 6; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1463 if (nFlags == RS_STIPCM32S) len += pIns->nLength * 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1464 if (len > dwMemLength) break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1465 if (len > 8*8) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1466 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1467 UINT slsize = (nFlags == RS_STIPCM32S) ? 4 : 3; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1468 LPBYTE pSrc = (LPBYTE)lpMemFile; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1469 LONG max = 255; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1470 if (nFlags == RS_STIPCM32S) pSrc++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1471 for (UINT j=0; j<len; j+=slsize) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1472 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1473 LONG l = ((((pSrc[j+2] << 8) + pSrc[j+1]) << 8) + pSrc[j]) << 8; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1474 l /= 256; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1475 if (l > max) max = l; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1476 if (-l > max) max = -l; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1477 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1478 max = (max / 128) + 1; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1479 signed short *pDest = (signed short *)pIns->pSample; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1480 for (UINT k=0; k<len; k+=slsize) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1481 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1482 LONG lr = ((((pSrc[k+2] << 8) + pSrc[k+1]) << 8) + pSrc[k]) << 8; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1483 k += slsize; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1484 LONG ll = ((((pSrc[k+2] << 8) + pSrc[k+1]) << 8) + pSrc[k]) << 8; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1485 pDest[0] = (signed short)ll; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1486 pDest[1] = (signed short)lr; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1487 pDest += 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1488 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1489 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1490 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1491 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1492 // 16-bit signed big endian interleaved stereo |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1493 case RS_STIPCM16M: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1494 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1495 len = pIns->nLength; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1496 if (len*4 > dwMemLength) len = dwMemLength >> 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1497 LPCBYTE psrc = (LPCBYTE)lpMemFile; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1498 short int *pSample = (short int *)pIns->pSample; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1499 for (UINT j=0; j<len; j++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1500 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1501 pSample[j*2] = (signed short)(((UINT)psrc[0] << 8) | (psrc[1])); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1502 pSample[j*2+1] = (signed short)(((UINT)psrc[2] << 8) | (psrc[3])); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1503 psrc += 4; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1504 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1505 len *= 4; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1506 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1507 break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1508 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1509 #endif // MODPLUG_TRACKER |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1510 #endif // !MODPLUG_FASTSOUNDLIB |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1511 #endif // !MODPLUG_BASIC_SUPPORT |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1512 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1513 // Default: 8-bit signed PCM data |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1514 default: |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1515 len = pIns->nLength; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1516 if (len > dwMemLength) len = pIns->nLength = dwMemLength; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1517 memcpy(pIns->pSample, lpMemFile, len); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1518 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1519 if (len > dwMemLength) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1520 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1521 if (pIns->pSample) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1522 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1523 pIns->nLength = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1524 FreeSample(pIns->pSample); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1525 pIns->pSample = NULL; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1526 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1527 return 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1528 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1529 AdjustSampleLoop(pIns); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1530 return len; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1531 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1532 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1533 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1534 void CSoundFile::AdjustSampleLoop(MODINSTRUMENT *pIns) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1535 //---------------------------------------------------- |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1536 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1537 if (!pIns->pSample) return; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1538 if (pIns->nLoopEnd > pIns->nLength) pIns->nLoopEnd = pIns->nLength; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1539 if (pIns->nLoopStart+2 >= pIns->nLoopEnd) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1540 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1541 pIns->nLoopStart = pIns->nLoopEnd = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1542 pIns->uFlags &= ~CHN_LOOP; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1543 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1544 UINT len = pIns->nLength; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1545 if (pIns->uFlags & CHN_16BIT) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1546 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1547 short int *pSample = (short int *)pIns->pSample; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1548 // Adjust end of sample |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1549 if (pIns->uFlags & CHN_STEREO) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1550 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1551 pSample[len*2+6] = pSample[len*2+4] = pSample[len*2+2] = pSample[len*2] = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1552 pSample[len*2+7] = pSample[len*2+5] = pSample[len*2+3] = pSample[len*2+1] = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1553 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1554 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1555 pSample[len+4] = pSample[len+3] = pSample[len+2] = pSample[len+1] = pSample[len] = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1556 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1557 if ((pIns->uFlags & (CHN_LOOP|CHN_PINGPONGLOOP|CHN_STEREO)) == CHN_LOOP) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1558 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1559 // Fix bad loops |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1560 if ((pIns->nLoopEnd+3 >= pIns->nLength) || (m_nType & MOD_TYPE_S3M)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1561 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1562 pSample[pIns->nLoopEnd] = pSample[pIns->nLoopStart]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1563 pSample[pIns->nLoopEnd+1] = pSample[pIns->nLoopStart+1]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1564 pSample[pIns->nLoopEnd+2] = pSample[pIns->nLoopStart+2]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1565 pSample[pIns->nLoopEnd+3] = pSample[pIns->nLoopStart+3]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1566 pSample[pIns->nLoopEnd+4] = pSample[pIns->nLoopStart+4]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1567 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1568 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1569 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1570 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1571 signed char *pSample = pIns->pSample; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1572 #ifndef MODPLUG_FASTSOUNDLIB |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1573 // Crappy samples (except chiptunes) ? |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1574 if ((pIns->nLength > 0x100) && (m_nType & (MOD_TYPE_MOD|MOD_TYPE_S3M)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1575 && (!(pIns->uFlags & CHN_STEREO))) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1576 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1577 int smpend = pSample[pIns->nLength-1], smpfix = 0, kscan; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1578 for (kscan=pIns->nLength-1; kscan>0; kscan--) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1579 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1580 smpfix = pSample[kscan-1]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1581 if (smpfix != smpend) break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1582 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1583 int delta = smpfix - smpend; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1584 if (((!(pIns->uFlags & CHN_LOOP)) || (kscan > (int)pIns->nLoopEnd)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1585 && ((delta < -8) || (delta > 8))) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1586 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1587 while (kscan<(int)pIns->nLength) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1588 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1589 if (!(kscan & 7)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1590 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1591 if (smpfix > 0) smpfix--; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1592 if (smpfix < 0) smpfix++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1593 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1594 pSample[kscan] = (signed char)smpfix; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1595 kscan++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1596 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1597 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1598 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1599 #endif |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1600 // Adjust end of sample |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1601 if (pIns->uFlags & CHN_STEREO) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1602 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1603 pSample[len*2+6] = pSample[len*2+4] = pSample[len*2+2] = pSample[len*2] = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1604 pSample[len*2+7] = pSample[len*2+5] = pSample[len*2+3] = pSample[len*2+1] = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1605 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1606 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1607 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1608 pSample[len+4] = pSample[len+3] = pSample[len+2] = pSample[len+1] = pSample[len] = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1609 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1610 if ((pIns->uFlags & (CHN_LOOP|CHN_PINGPONGLOOP|CHN_STEREO)) == CHN_LOOP) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1611 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1612 if ((pIns->nLoopEnd+3 >= pIns->nLength) || (m_nType & (MOD_TYPE_MOD|MOD_TYPE_S3M))) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1613 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1614 pSample[pIns->nLoopEnd] = pSample[pIns->nLoopStart]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1615 pSample[pIns->nLoopEnd+1] = pSample[pIns->nLoopStart+1]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1616 pSample[pIns->nLoopEnd+2] = pSample[pIns->nLoopStart+2]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1617 pSample[pIns->nLoopEnd+3] = pSample[pIns->nLoopStart+3]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1618 pSample[pIns->nLoopEnd+4] = pSample[pIns->nLoopStart+4]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1619 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1620 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1621 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1622 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1623 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1624 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1625 ///////////////////////////////////////////////////////////// |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1626 // Transpose <-> Frequency conversions |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1627 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1628 // returns 8363*2^((transp*128+ftune)/(12*128)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1629 DWORD CSoundFile::TransposeToFrequency(int transp, int ftune) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1630 //----------------------------------------------------------- |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1631 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1632 //---GCCFIX: Removed assembly. |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1633 return (DWORD)(8363*pow(2, (transp*128+ftune)/(1536))); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1634 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1635 #ifdef MSC_VER |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1636 const float _fbase = 8363; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1637 const float _factor = 1.0f/(12.0f*128.0f); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1638 int result; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1639 DWORD freq; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1640 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1641 transp = (transp << 7) + ftune; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1642 _asm { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1643 fild transp |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1644 fld _factor |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1645 fmulp st(1), st(0) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1646 fist result |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1647 fisub result |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1648 f2xm1 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1649 fild result |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1650 fld _fbase |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1651 fscale |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1652 fstp st(1) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1653 fmul st(1), st(0) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1654 faddp st(1), st(0) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1655 fistp freq |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1656 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1657 UINT derr = freq % 11025; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1658 if (derr <= 8) freq -= derr; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1659 if (derr >= 11015) freq += 11025-derr; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1660 derr = freq % 1000; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1661 if (derr <= 5) freq -= derr; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1662 if (derr >= 995) freq += 1000-derr; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1663 return freq; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1664 #endif |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1665 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1666 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1667 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1668 // returns 12*128*log2(freq/8363) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1669 int CSoundFile::FrequencyToTranspose(DWORD freq) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1670 //---------------------------------------------- |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1671 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1672 //---GCCFIX: Removed assembly. |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1673 return int(1536*(log(freq/8363)/log(2))); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1674 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1675 #ifdef MSC_VER |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1676 const float _f1_8363 = 1.0f / 8363.0f; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1677 const float _factor = 128 * 12; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1678 LONG result; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1679 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1680 if (!freq) return 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1681 _asm { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1682 fld _factor |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1683 fild freq |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1684 fld _f1_8363 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1685 fmulp st(1), st(0) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1686 fyl2x |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1687 fistp result |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1688 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1689 return result; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1690 #endif |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1691 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1692 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1693 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1694 void CSoundFile::FrequencyToTranspose(MODINSTRUMENT *psmp) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1695 //-------------------------------------------------------- |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1696 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1697 int f2t = FrequencyToTranspose(psmp->nC4Speed); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1698 int transp = f2t >> 7; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1699 int ftune = f2t & 0x7F; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1700 if (ftune > 80) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1701 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1702 transp++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1703 ftune -= 128; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1704 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1705 if (transp > 127) transp = 127; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1706 if (transp < -127) transp = -127; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1707 psmp->RelativeTone = transp; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1708 psmp->nFineTune = ftune; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1709 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1710 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1711 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1712 void CSoundFile::CheckCPUUsage(UINT nCPU) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1713 //--------------------------------------- |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1714 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1715 if (nCPU > 100) nCPU = 100; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1716 gnCPUUsage = nCPU; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1717 if (nCPU < 90) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1718 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1719 m_dwSongFlags &= ~SONG_CPUVERYHIGH; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1720 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1721 if ((m_dwSongFlags & SONG_CPUVERYHIGH) && (nCPU >= 94)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1722 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1723 UINT i=MAX_CHANNELS; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1724 while (i >= 8) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1725 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1726 i--; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1727 if (Chn[i].nLength) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1728 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1729 Chn[i].nLength = Chn[i].nPos = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1730 nCPU -= 2; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1731 if (nCPU < 94) break; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1732 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1733 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1734 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1735 if (nCPU > 90) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1736 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1737 m_dwSongFlags |= SONG_CPUVERYHIGH; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1738 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1739 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1740 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1741 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1742 BOOL CSoundFile::SetPatternName(UINT nPat, LPCSTR lpszName) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1743 //--------------------------------------------------------- |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1744 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1745 char szName[MAX_PATTERNNAME] = ""; // changed from CHAR |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1746 if (nPat >= MAX_PATTERNS) return FALSE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1747 if (lpszName) lstrcpyn(szName, lpszName, MAX_PATTERNNAME); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1748 szName[MAX_PATTERNNAME-1] = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1749 if (!m_lpszPatternNames) m_nPatternNames = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1750 if (nPat >= m_nPatternNames) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1751 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1752 if (!lpszName[0]) return TRUE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1753 UINT len = (nPat+1)*MAX_PATTERNNAME; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1754 char *p = new char[len]; // changed from CHAR |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1755 if (!p) return FALSE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1756 memset(p, 0, len); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1757 if (m_lpszPatternNames) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1758 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1759 memcpy(p, m_lpszPatternNames, m_nPatternNames * MAX_PATTERNNAME); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1760 delete m_lpszPatternNames; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1761 m_lpszPatternNames = NULL; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1762 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1763 m_lpszPatternNames = p; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1764 m_nPatternNames = nPat + 1; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1765 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1766 memcpy(m_lpszPatternNames + nPat * MAX_PATTERNNAME, szName, MAX_PATTERNNAME); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1767 return TRUE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1768 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1769 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1770 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1771 BOOL CSoundFile::GetPatternName(UINT nPat, LPSTR lpszName, UINT cbSize) const |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1772 //--------------------------------------------------------------------------- |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1773 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1774 if ((!lpszName) || (!cbSize)) return FALSE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1775 lpszName[0] = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1776 if (cbSize > MAX_PATTERNNAME) cbSize = MAX_PATTERNNAME; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1777 if ((m_lpszPatternNames) && (nPat < m_nPatternNames)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1778 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1779 memcpy(lpszName, m_lpszPatternNames + nPat * MAX_PATTERNNAME, cbSize); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1780 lpszName[cbSize-1] = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1781 return TRUE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1782 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1783 return FALSE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1784 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1785 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1786 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1787 #ifndef MODPLUG_FASTSOUNDLIB |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1788 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1789 UINT CSoundFile::DetectUnusedSamples(BOOL *pbIns) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1790 //----------------------------------------------- |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1791 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1792 UINT nExt = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1793 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1794 if (!pbIns) return 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1795 if (m_nInstruments) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1796 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1797 memset(pbIns, 0, MAX_SAMPLES * sizeof(BOOL)); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1798 for (UINT ipat=0; ipat<MAX_PATTERNS; ipat++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1799 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1800 MODCOMMAND *p = Patterns[ipat]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1801 if (p) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1802 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1803 UINT jmax = PatternSize[ipat] * m_nChannels; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1804 for (UINT j=0; j<jmax; j++, p++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1805 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1806 if ((p->note) && (p->note <= 120)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1807 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1808 if ((p->instr) && (p->instr < MAX_INSTRUMENTS)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1809 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1810 INSTRUMENTHEADER *penv = Headers[p->instr]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1811 if (penv) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1812 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1813 UINT n = penv->Keyboard[p->note-1]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1814 if (n < MAX_SAMPLES) pbIns[n] = TRUE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1815 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1816 } else |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1817 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1818 for (UINT k=1; k<=m_nInstruments; k++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1819 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1820 INSTRUMENTHEADER *penv = Headers[k]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1821 if (penv) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1822 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1823 UINT n = penv->Keyboard[p->note-1]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1824 if (n < MAX_SAMPLES) pbIns[n] = TRUE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1825 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1826 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1827 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1828 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1829 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1830 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1831 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1832 for (UINT ichk=1; ichk<=m_nSamples; ichk++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1833 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1834 if ((!pbIns[ichk]) && (Ins[ichk].pSample)) nExt++; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1835 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1836 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1837 return nExt; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1838 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1839 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1840 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1841 BOOL CSoundFile::RemoveSelectedSamples(BOOL *pbIns) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1842 //------------------------------------------------- |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1843 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1844 if (!pbIns) return FALSE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1845 for (UINT j=1; j<MAX_SAMPLES; j++) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1846 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1847 if ((!pbIns[j]) && (Ins[j].pSample)) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1848 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1849 DestroySample(j); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1850 if ((j == m_nSamples) && (j > 1)) m_nSamples--; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1851 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1852 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1853 return TRUE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1854 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1855 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1856 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1857 BOOL CSoundFile::DestroySample(UINT nSample) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1858 //------------------------------------------ |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1859 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1860 if ((!nSample) || (nSample >= MAX_SAMPLES)) return FALSE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1861 if (!Ins[nSample].pSample) return TRUE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1862 MODINSTRUMENT *pins = &Ins[nSample]; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1863 signed char *pSample = pins->pSample; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1864 pins->pSample = NULL; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1865 pins->nLength = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1866 pins->uFlags &= ~(CHN_16BIT); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1867 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
|
1868 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1869 if (Chn[i].pSample == pSample) |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1870 { |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1871 Chn[i].nPos = Chn[i].nLength = 0; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1872 Chn[i].pSample = Chn[i].pCurrentSample = NULL; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1873 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1874 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1875 FreeSample(pSample); |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1876 return TRUE; |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1877 } |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1878 |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1879 #endif // MODPLUG_FASTSOUNDLIB |
6b5a52635b3b
[svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff
changeset
|
1880 |