| 1 | /* |
| 2 | * This source code is public domain. |
| 3 | * |
| 4 | * Authors: Olivier Lapicque <[email protected]>, |
| 5 | * Adam Goode <[email protected]> (endian and char fixes for PPC) |
| 6 | */ |
| 7 | |
| 8 | #include <math.h> |
| 9 | #include "stdafx.h"cxx . . $ `<file>/ext/psmplug/stdafx.h`/ |
| 10 | #include "sndfile.h"cxx . . $ `<file>/ext/psmplug/sndfile.h`/ |
| 11 | |
| 12 | |
| 13 | ////////////////////////////////////////////////////////// |
| 14 | // CSoundFile |
| 15 | |
| 16 | CSoundFilecxx . . $ CSoundFile#::CSoundFilecxx . . $ CSoundFile#CSoundFile(49f6e7a06ebc5aa8).() |
| 17 | //---------------------- |
| 18 | { |
| 19 | m_nTypecxx . . $ CSoundFile#m_nType. = MOD_TYPE_NONEcxx . . $ `ext/psmplug/sndfile.h:39:9`!; |
| 20 | m_dwSongFlagscxx . . $ CSoundFile#m_dwSongFlags. = 0; |
| 21 | m_nChannelscxx . . $ CSoundFile#m_nChannels. = 0; |
| 22 | m_nMixChannelscxx . . $ CSoundFile#m_nMixChannels. = 0; |
| 23 | m_nSamplescxx . . $ CSoundFile#m_nSamples. = 0; |
| 24 | m_nInstrumentscxx . . $ CSoundFile#m_nInstruments. = 0; |
| 25 | m_nPatternNamescxx . . $ CSoundFile#m_nPatternNames. = 0; |
| 26 | m_lpszPatternNamescxx . . $ CSoundFile#m_lpszPatternNames. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 27 | m_lpszSongCommentscxx . . $ CSoundFile#m_lpszSongComments. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 28 | m_nFreqFactorcxx . . $ CSoundFile#m_nFreqFactor. = m_nTempoFactorcxx . . $ CSoundFile#m_nTempoFactor. = 128; |
| 29 | m_nMasterVolumecxx . . $ CSoundFile#m_nMasterVolume. = 128; |
| 30 | m_nMinPeriodcxx . . $ CSoundFile#m_nMinPeriod. = 0x20; |
| 31 | m_nMaxPeriodcxx . . $ CSoundFile#m_nMaxPeriod. = 0x7FFF; |
| 32 | m_nRepeatCountcxx . . $ CSoundFile#m_nRepeatCount. = 0; |
| 33 | memset(Chncxx . . $ CSoundFile#Chn., 0, sizeof(Chncxx . . $ CSoundFile#Chn.)); |
| 34 | memset(ChnMixcxx . . $ CSoundFile#ChnMix., 0, sizeof(ChnMixcxx . . $ CSoundFile#ChnMix.)); |
| 35 | memset(Inscxx . . $ CSoundFile#Ins., 0, sizeof(Inscxx . . $ CSoundFile#Ins.)); |
| 36 | memset(ChnSettingscxx . . $ CSoundFile#ChnSettings., 0, sizeof(ChnSettingscxx . . $ CSoundFile#ChnSettings.)); |
| 37 | memset(Headerscxx . . $ CSoundFile#Headers., 0, sizeof(Headerscxx . . $ CSoundFile#Headers.)); |
| 38 | memset(Ordercxx . . $ CSoundFile#Order., 0xFF, sizeof(Ordercxx . . $ CSoundFile#Order.)); |
| 39 | memset(Patternscxx . . $ CSoundFile#Patterns., 0, sizeof(Patternscxx . . $ CSoundFile#Patterns.)); |
| 40 | memset(m_szNamescxx . . $ CSoundFile#m_szNames., 0, sizeof(m_szNamescxx . . $ CSoundFile#m_szNames.)); |
| 41 | memset(m_MixPluginscxx . . $ CSoundFile#m_MixPlugins., 0, sizeof(m_MixPluginscxx . . $ CSoundFile#m_MixPlugins.)); |
| 42 | } |
| 43 | |
| 44 | |
| 45 | CSoundFilecxx . . $ CSoundFile#::~cxx . . $ CSoundFile#`~CSoundFile`(49f6e7a06ebc5aa8).CSoundFilecxx . . $ CSoundFile#() |
| 46 | //----------------------- |
| 47 | { |
| 48 | Destroycxx . . $ CSoundFile#Destroy(c9857a73d68e59ba).(); |
| 49 | } |
| 50 | |
| 51 | |
| 52 | BOOLcxx . . $ BOOL# CSoundFilecxx . . $ CSoundFile#::Createcxx . . $ CSoundFile#Create(41ee87f0602ae969).(LPCBYTEcxx . . $ LPCBYTE# lpStream, DWORDcxx . . $ DWORD# dwMemLength) |
| 53 | //---------------------------------------------------------- |
| 54 | { |
| 55 | int i; |
| 56 | |
| 57 | m_nTypecxx . . $ CSoundFile#m_nType. = MOD_TYPE_NONEcxx . . $ `ext/psmplug/sndfile.h:39:9`!; |
| 58 | m_dwSongFlagscxx . . $ CSoundFile#m_dwSongFlags. = 0; |
| 59 | m_nChannelscxx . . $ CSoundFile#m_nChannels. = 0; |
| 60 | m_nMixChannelscxx . . $ CSoundFile#m_nMixChannels. = 0; |
| 61 | m_nSamplescxx . . $ CSoundFile#m_nSamples. = 0; |
| 62 | m_nInstrumentscxx . . $ CSoundFile#m_nInstruments. = 0; |
| 63 | m_nFreqFactorcxx . . $ CSoundFile#m_nFreqFactor. = m_nTempoFactorcxx . . $ CSoundFile#m_nTempoFactor. = 128; |
| 64 | m_nMasterVolumecxx . . $ CSoundFile#m_nMasterVolume. = 128; |
| 65 | m_nDefaultGlobalVolumecxx . . $ CSoundFile#m_nDefaultGlobalVolume. = 256; |
| 66 | m_nGlobalVolumecxx . . $ CSoundFile#m_nGlobalVolume. = 256; |
| 67 | m_nOldGlbVolSlidecxx . . $ CSoundFile#m_nOldGlbVolSlide. = 0; |
| 68 | m_nDefaultSpeedcxx . . $ CSoundFile#m_nDefaultSpeed. = 6; |
| 69 | m_nDefaultTempocxx . . $ CSoundFile#m_nDefaultTempo. = 125; |
| 70 | m_nPatternDelaycxx . . $ CSoundFile#m_nPatternDelay. = 0; |
| 71 | m_nFrameDelaycxx . . $ CSoundFile#m_nFrameDelay. = 0; |
| 72 | m_nNextRowcxx . . $ CSoundFile#m_nNextRow. = 0; |
| 73 | m_nRowcxx . . $ CSoundFile#m_nRow. = 0; |
| 74 | m_nNextStartRowcxx . . $ CSoundFile#m_nNextStartRow. = 0; |
| 75 | m_nPatterncxx . . $ CSoundFile#m_nPattern. = 0; |
| 76 | m_nCurrentPatterncxx . . $ CSoundFile#m_nCurrentPattern. = 0; |
| 77 | m_nNextPatterncxx . . $ CSoundFile#m_nNextPattern. = 0; |
| 78 | m_nRestartPoscxx . . $ CSoundFile#m_nRestartPos. = 0; |
| 79 | m_nMinPeriodcxx . . $ CSoundFile#m_nMinPeriod. = 16; |
| 80 | m_nMaxPeriodcxx . . $ CSoundFile#m_nMaxPeriod. = 32767; |
| 81 | m_nSongPreAmpcxx . . $ CSoundFile#m_nSongPreAmp. = 0x30; |
| 82 | m_nPatternNamescxx . . $ CSoundFile#m_nPatternNames. = 0; |
| 83 | m_nMaxOrderPositioncxx . . $ CSoundFile#m_nMaxOrderPosition. = 0; |
| 84 | m_lpszPatternNamescxx . . $ CSoundFile#m_lpszPatternNames. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 85 | m_lpszSongCommentscxx . . $ CSoundFile#m_lpszSongComments. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 86 | memset(Inscxx . . $ CSoundFile#Ins., 0, sizeof(Inscxx . . $ CSoundFile#Ins.)); |
| 87 | memset(ChnMixcxx . . $ CSoundFile#ChnMix., 0, sizeof(ChnMixcxx . . $ CSoundFile#ChnMix.)); |
| 88 | memset(Chncxx . . $ CSoundFile#Chn., 0, sizeof(Chncxx . . $ CSoundFile#Chn.)); |
| 89 | memset(Headerscxx . . $ CSoundFile#Headers., 0, sizeof(Headerscxx . . $ CSoundFile#Headers.)); |
| 90 | memset(Ordercxx . . $ CSoundFile#Order., 0xFF, sizeof(Ordercxx . . $ CSoundFile#Order.)); |
| 91 | memset(Patternscxx . . $ CSoundFile#Patterns., 0, sizeof(Patternscxx . . $ CSoundFile#Patterns.)); |
| 92 | memset(m_szNamescxx . . $ CSoundFile#m_szNames., 0, sizeof(m_szNamescxx . . $ CSoundFile#m_szNames.)); |
| 93 | memset(m_MixPluginscxx . . $ CSoundFile#m_MixPlugins., 0, sizeof(m_MixPluginscxx . . $ CSoundFile#m_MixPlugins.)); |
| 94 | ResetMidiCfgcxx . . $ CSoundFile#ResetMidiCfg(49f6e7a06ebc5aa8).(); |
| 95 | for (UINTcxx . . $ UINT# npt=0; npt<MAX_PATTERNScxx . . $ `ext/psmplug/sndfile.h:24:9`!; npt++) PatternSizecxx . . $ CSoundFile#PatternSize.[npt] = 64; |
| 96 | for (UINTcxx . . $ UINT# nch=0; nch<MAX_BASECHANNELScxx . . $ `ext/psmplug/sndfile.h:28:9`!; nch++) |
| 97 | { |
| 98 | ChnSettingscxx . . $ CSoundFile#ChnSettings.[nch].nPancxx . . $ _MODCHANNELSETTINGS#nPan. = 128; |
| 99 | ChnSettingscxx . . $ CSoundFile#ChnSettings.[nch].nVolumecxx . . $ _MODCHANNELSETTINGS#nVolume. = 64; |
| 100 | ChnSettingscxx . . $ CSoundFile#ChnSettings.[nch].dwFlagscxx . . $ _MODCHANNELSETTINGS#dwFlags. = 0; |
| 101 | ChnSettingscxx . . $ CSoundFile#ChnSettings.[nch].szNamecxx . . $ _MODCHANNELSETTINGS#szName.[0] = 0; |
| 102 | } |
| 103 | if (lpStream) |
| 104 | { |
| 105 | if (!ReadPSMcxx . . $ CSoundFile#ReadPSM(41ee87f0602ae969).(lpStream, dwMemLength)) |
| 106 | m_nTypecxx . . $ CSoundFile#m_nType. = MOD_TYPE_NONEcxx . . $ `ext/psmplug/sndfile.h:39:9`!; |
| 107 | } |
| 108 | // Adjust song names |
| 109 | for (i=0; i<MAX_SAMPLEScxx . . $ `ext/psmplug/sndfile.h:25:9`!; i++) |
| 110 | { |
| 111 | LPSTRcxx . . $ LPSTR# p = m_szNamescxx . . $ CSoundFile#m_szNames.[i]; |
| 112 | int j = 31; |
| 113 | p[j] = 0; |
| 114 | while ((j>=0) && (p[j]<=' ')) p[j--] = 0; |
| 115 | while (j>=0) |
| 116 | { |
| 117 | if (((BYTEcxx . . $ BYTE#)p[j]) < ' ') p[j] = ' '; |
| 118 | j--; |
| 119 | } |
| 120 | } |
| 121 | // Adjust channels |
| 122 | for (i=0; i<MAX_BASECHANNELScxx . . $ `ext/psmplug/sndfile.h:28:9`!; i++) |
| 123 | { |
| 124 | if (ChnSettingscxx . . $ CSoundFile#ChnSettings.[i].nVolumecxx . . $ _MODCHANNELSETTINGS#nVolume. > 64) ChnSettingscxx . . $ CSoundFile#ChnSettings.[i].nVolumecxx . . $ _MODCHANNELSETTINGS#nVolume. = 64; |
| 125 | if (ChnSettingscxx . . $ CSoundFile#ChnSettings.[i].nPancxx . . $ _MODCHANNELSETTINGS#nPan. > 256) ChnSettingscxx . . $ CSoundFile#ChnSettings.[i].nPancxx . . $ _MODCHANNELSETTINGS#nPan. = 128; |
| 126 | Chncxx . . $ CSoundFile#Chn.[i].nPancxx . . $ _MODCHANNEL#nPan. = ChnSettingscxx . . $ CSoundFile#ChnSettings.[i].nPancxx . . $ _MODCHANNELSETTINGS#nPan.; |
| 127 | Chncxx . . $ CSoundFile#Chn.[i].nGlobalVolcxx . . $ _MODCHANNEL#nGlobalVol. = ChnSettingscxx . . $ CSoundFile#ChnSettings.[i].nVolumecxx . . $ _MODCHANNELSETTINGS#nVolume.; |
| 128 | Chncxx . . $ CSoundFile#Chn.[i].dwFlagscxx . . $ _MODCHANNEL#dwFlags. = ChnSettingscxx . . $ CSoundFile#ChnSettings.[i].dwFlagscxx . . $ _MODCHANNELSETTINGS#dwFlags.; |
| 129 | Chncxx . . $ CSoundFile#Chn.[i].nVolumecxx . . $ _MODCHANNEL#nVolume. = 256; |
| 130 | Chncxx . . $ CSoundFile#Chn.[i].nCutOffcxx . . $ _MODCHANNEL#nCutOff. = 0x7F; |
| 131 | } |
| 132 | // Checking instruments |
| 133 | MODINSTRUMENTcxx . . $ MODINSTRUMENT# *pins = Inscxx . . $ CSoundFile#Ins.; |
| 134 | |
| 135 | for (i=0; i<MAX_INSTRUMENTScxx . . $ `ext/psmplug/sndfile.h:26:9`!; i++, pins++) |
| 136 | { |
| 137 | if (pins->pSamplecxx . . $ _MODINSTRUMENT#pSample.) |
| 138 | { |
| 139 | if (pins->nLoopEndcxx . . $ _MODINSTRUMENT#nLoopEnd. > pins->nLengthcxx . . $ _MODINSTRUMENT#nLength.) pins->nLoopEndcxx . . $ _MODINSTRUMENT#nLoopEnd. = pins->nLengthcxx . . $ _MODINSTRUMENT#nLength.; |
| 140 | if (pins->nLoopStartcxx . . $ _MODINSTRUMENT#nLoopStart. + 3 >= pins->nLoopEndcxx . . $ _MODINSTRUMENT#nLoopEnd.) |
| 141 | { |
| 142 | pins->nLoopStartcxx . . $ _MODINSTRUMENT#nLoopStart. = 0; |
| 143 | pins->nLoopEndcxx . . $ _MODINSTRUMENT#nLoopEnd. = 0; |
| 144 | } |
| 145 | if (pins->nSustainEndcxx . . $ _MODINSTRUMENT#nSustainEnd. > pins->nLengthcxx . . $ _MODINSTRUMENT#nLength.) pins->nSustainEndcxx . . $ _MODINSTRUMENT#nSustainEnd. = pins->nLengthcxx . . $ _MODINSTRUMENT#nLength.; |
| 146 | if (pins->nSustainStartcxx . . $ _MODINSTRUMENT#nSustainStart. + 3 >= pins->nSustainEndcxx . . $ _MODINSTRUMENT#nSustainEnd.) |
| 147 | { |
| 148 | pins->nSustainStartcxx . . $ _MODINSTRUMENT#nSustainStart. = 0; |
| 149 | pins->nSustainEndcxx . . $ _MODINSTRUMENT#nSustainEnd. = 0; |
| 150 | } |
| 151 | } else |
| 152 | { |
| 153 | pins->nLengthcxx . . $ _MODINSTRUMENT#nLength. = 0; |
| 154 | pins->nLoopStartcxx . . $ _MODINSTRUMENT#nLoopStart. = 0; |
| 155 | pins->nLoopEndcxx . . $ _MODINSTRUMENT#nLoopEnd. = 0; |
| 156 | pins->nSustainStartcxx . . $ _MODINSTRUMENT#nSustainStart. = 0; |
| 157 | pins->nSustainEndcxx . . $ _MODINSTRUMENT#nSustainEnd. = 0; |
| 158 | } |
| 159 | if (!pins->nLoopEndcxx . . $ _MODINSTRUMENT#nLoopEnd.) pins->uFlagscxx . . $ _MODINSTRUMENT#uFlags. &= ~CHN_LOOPcxx . . $ `ext/psmplug/sndfile.h:74:9`!; |
| 160 | if (!pins->nSustainEndcxx . . $ _MODINSTRUMENT#nSustainEnd.) pins->uFlagscxx . . $ _MODINSTRUMENT#uFlags. &= ~CHN_SUSTAINLOOPcxx . . $ `ext/psmplug/sndfile.h:76:9`!; |
| 161 | if (pins->nGlobalVolcxx . . $ _MODINSTRUMENT#nGlobalVol. > 64) pins->nGlobalVolcxx . . $ _MODINSTRUMENT#nGlobalVol. = 64; |
| 162 | } |
| 163 | // Check invalid instruments |
| 164 | while ((m_nInstrumentscxx . . $ CSoundFile#m_nInstruments. > 0) && (!Headerscxx . . $ CSoundFile#Headers.[m_nInstrumentscxx . . $ CSoundFile#m_nInstruments.])) |
| 165 | m_nInstrumentscxx . . $ CSoundFile#m_nInstruments.--; |
| 166 | // Set default values |
| 167 | if (m_nSongPreAmpcxx . . $ CSoundFile#m_nSongPreAmp. < 0x20) m_nSongPreAmpcxx . . $ CSoundFile#m_nSongPreAmp. = 0x20; |
| 168 | if (m_nDefaultTempocxx . . $ CSoundFile#m_nDefaultTempo. < 32) m_nDefaultTempocxx . . $ CSoundFile#m_nDefaultTempo. = 125; |
| 169 | if (!m_nDefaultSpeedcxx . . $ CSoundFile#m_nDefaultSpeed.) m_nDefaultSpeedcxx . . $ CSoundFile#m_nDefaultSpeed. = 6; |
| 170 | m_nMusicSpeedcxx . . $ CSoundFile#m_nMusicSpeed. = m_nDefaultSpeedcxx . . $ CSoundFile#m_nDefaultSpeed.; |
| 171 | m_nMusicTempocxx . . $ CSoundFile#m_nMusicTempo. = m_nDefaultTempocxx . . $ CSoundFile#m_nDefaultTempo.; |
| 172 | m_nGlobalVolumecxx . . $ CSoundFile#m_nGlobalVolume. = m_nDefaultGlobalVolumecxx . . $ CSoundFile#m_nDefaultGlobalVolume.; |
| 173 | m_nNextPatterncxx . . $ CSoundFile#m_nNextPattern. = 0; |
| 174 | m_nCurrentPatterncxx . . $ CSoundFile#m_nCurrentPattern. = 0; |
| 175 | m_nPatterncxx . . $ CSoundFile#m_nPattern. = 0; |
| 176 | m_nBufferCountcxx . . $ CSoundFile#m_nBufferCount. = 0; |
| 177 | m_nTickCountcxx . . $ CSoundFile#m_nTickCount. = m_nMusicSpeedcxx . . $ CSoundFile#m_nMusicSpeed.; |
| 178 | m_nNextRowcxx . . $ CSoundFile#m_nNextRow. = 0; |
| 179 | m_nRowcxx . . $ CSoundFile#m_nRow. = 0; |
| 180 | m_nNextStartRowcxx . . $ CSoundFile#m_nNextStartRow. = 0; |
| 181 | if ((m_nRestartPoscxx . . $ CSoundFile#m_nRestartPos. >= MAX_ORDERScxx . . $ `ext/psmplug/sndfile.h:23:9`!) || (Ordercxx . . $ CSoundFile#Order.[m_nRestartPoscxx . . $ CSoundFile#m_nRestartPos.] >= MAX_PATTERNScxx . . $ `ext/psmplug/sndfile.h:24:9`!)) m_nRestartPoscxx . . $ CSoundFile#m_nRestartPos. = 0; |
| 182 | // Load plugins |
| 183 | if (gpMixPluginCreateProccxx . . $ CSoundFile#gpMixPluginCreateProc.) |
| 184 | { |
| 185 | for (UINTcxx . . $ UINT# iPlug=0; iPlug<MAX_MIXPLUGINScxx . . $ `ext/psmplug/sndfile.h:36:9`!; iPlug++) |
| 186 | { |
| 187 | if ((m_MixPluginscxx . . $ CSoundFile#m_MixPlugins.[iPlug].Infocxx . . $ _SNDMIXPLUGIN#Info..dwPluginId1cxx . . $ _SNDMIXPLUGININFO#dwPluginId1.) |
| 188 | || (m_MixPluginscxx . . $ CSoundFile#m_MixPlugins.[iPlug].Infocxx . . $ _SNDMIXPLUGIN#Info..dwPluginId2cxx . . $ _SNDMIXPLUGININFO#dwPluginId2.)) |
| 189 | { |
| 190 | gpMixPluginCreateProccxx . . $ CSoundFile#gpMixPluginCreateProc.(&m_MixPluginscxx . . $ CSoundFile#m_MixPlugins.[iPlug]); |
| 191 | if (m_MixPluginscxx . . $ CSoundFile#m_MixPlugins.[iPlug].pMixPlugincxx . . $ _SNDMIXPLUGIN#pMixPlugin.) |
| 192 | { |
| 193 | m_MixPluginscxx . . $ CSoundFile#m_MixPlugins.[iPlug].pMixPlugincxx . . $ _SNDMIXPLUGIN#pMixPlugin.->RestoreAllParameterscxx . . $ IMixPlugin#RestoreAllParameters(49f6e7a06ebc5aa8).(); |
| 194 | } |
| 195 | } |
| 196 | } |
| 197 | } |
| 198 | if (m_nTypecxx . . $ CSoundFile#m_nType.) |
| 199 | { |
| 200 | UINTcxx . . $ UINT# maxpreamp = 0x10+(m_nChannelscxx . . $ CSoundFile#m_nChannels.*8); |
| 201 | if (maxpreamp > 100) maxpreamp = 100; |
| 202 | if (m_nSongPreAmpcxx . . $ CSoundFile#m_nSongPreAmp. > maxpreamp) m_nSongPreAmpcxx . . $ CSoundFile#m_nSongPreAmp. = maxpreamp; |
| 203 | return TRUEcxx . . $ `ext/psmplug/stdafx.h:97:9`!; |
| 204 | } |
| 205 | return FALSEcxx . . $ `ext/psmplug/stdafx.h:93:9`!; |
| 206 | } |
| 207 | |
| 208 | |
| 209 | BOOLcxx . . $ BOOL# CSoundFilecxx . . $ CSoundFile#::Destroycxx . . $ CSoundFile#Destroy(c9857a73d68e59ba).() |
| 210 | |
| 211 | //------------------------ |
| 212 | { |
| 213 | int i; |
| 214 | for (i=0; i<MAX_PATTERNScxx . . $ `ext/psmplug/sndfile.h:24:9`!; i++) if (Patternscxx . . $ CSoundFile#Patterns.[i]) |
| 215 | { |
| 216 | FreePatterncxx . . $ CSoundFile#FreePattern(5d22bdacc48458e8).(Patternscxx . . $ CSoundFile#Patterns.[i]); |
| 217 | Patternscxx . . $ CSoundFile#Patterns.[i] = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 218 | } |
| 219 | m_nPatternNamescxx . . $ CSoundFile#m_nPatternNames. = 0; |
| 220 | if (m_lpszPatternNamescxx . . $ CSoundFile#m_lpszPatternNames.) |
| 221 | { |
| 222 | delete [] m_lpszPatternNamescxx . . $ CSoundFile#m_lpszPatternNames.; |
| 223 | m_lpszPatternNamescxx . . $ CSoundFile#m_lpszPatternNames. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 224 | } |
| 225 | if (m_lpszSongCommentscxx . . $ CSoundFile#m_lpszSongComments.) |
| 226 | { |
| 227 | delete [] m_lpszSongCommentscxx . . $ CSoundFile#m_lpszSongComments.; |
| 228 | m_lpszSongCommentscxx . . $ CSoundFile#m_lpszSongComments. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 229 | } |
| 230 | for (i=1; i<MAX_SAMPLEScxx . . $ `ext/psmplug/sndfile.h:25:9`!; i++) |
| 231 | { |
| 232 | MODINSTRUMENTcxx . . $ MODINSTRUMENT# *pins = &Inscxx . . $ CSoundFile#Ins.[i]; |
| 233 | if (pins->pSamplecxx . . $ _MODINSTRUMENT#pSample.) |
| 234 | { |
| 235 | FreeSamplecxx . . $ CSoundFile#FreeSample(5d22bdacc48458e8).(pins->pSamplecxx . . $ _MODINSTRUMENT#pSample.); |
| 236 | pins->pSamplecxx . . $ _MODINSTRUMENT#pSample. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 237 | } |
| 238 | } |
| 239 | for (i=0; i<MAX_INSTRUMENTScxx . . $ `ext/psmplug/sndfile.h:26:9`!; i++) |
| 240 | { |
| 241 | if (Headerscxx . . $ CSoundFile#Headers.[i]) |
| 242 | { |
| 243 | delete Headerscxx . . $ CSoundFile#Headers.[i]; |
| 244 | Headerscxx . . $ CSoundFile#Headers.[i] = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 245 | } |
| 246 | } |
| 247 | for (i=0; i<MAX_MIXPLUGINScxx . . $ `ext/psmplug/sndfile.h:36:9`!; i++) |
| 248 | { |
| 249 | if ((m_MixPluginscxx . . $ CSoundFile#m_MixPlugins.[i].nPluginDataSizecxx . . $ _SNDMIXPLUGIN#nPluginDataSize.) && (m_MixPluginscxx . . $ CSoundFile#m_MixPlugins.[i].pPluginDatacxx . . $ _SNDMIXPLUGIN#pPluginData.)) |
| 250 | { |
| 251 | m_MixPluginscxx . . $ CSoundFile#m_MixPlugins.[i].nPluginDataSizecxx . . $ _SNDMIXPLUGIN#nPluginDataSize. = 0; |
| 252 | delete [] (signed char*)m_MixPluginscxx . . $ CSoundFile#m_MixPlugins.[i].pPluginDatacxx . . $ _SNDMIXPLUGIN#pPluginData.; |
| 253 | m_MixPluginscxx . . $ CSoundFile#m_MixPlugins.[i].pPluginDatacxx . . $ _SNDMIXPLUGIN#pPluginData. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 254 | } |
| 255 | m_MixPluginscxx . . $ CSoundFile#m_MixPlugins.[i].pMixStatecxx . . $ _SNDMIXPLUGIN#pMixState. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 256 | if (m_MixPluginscxx . . $ CSoundFile#m_MixPlugins.[i].pMixPlugincxx . . $ _SNDMIXPLUGIN#pMixPlugin.) |
| 257 | { |
| 258 | m_MixPluginscxx . . $ CSoundFile#m_MixPlugins.[i].pMixPlugincxx . . $ _SNDMIXPLUGIN#pMixPlugin.->Releasecxx . . $ IMixPlugin#Release(b126dc7c1de90089).(); |
| 259 | m_MixPluginscxx . . $ CSoundFile#m_MixPlugins.[i].pMixPlugincxx . . $ _SNDMIXPLUGIN#pMixPlugin. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 260 | } |
| 261 | } |
| 262 | m_nTypecxx . . $ CSoundFile#m_nType. = MOD_TYPE_NONEcxx . . $ `ext/psmplug/sndfile.h:39:9`!; |
| 263 | m_nChannelscxx . . $ CSoundFile#m_nChannels. = m_nSamplescxx . . $ CSoundFile#m_nSamples. = m_nInstrumentscxx . . $ CSoundFile#m_nInstruments. = 0; |
| 264 | return TRUEcxx . . $ `ext/psmplug/stdafx.h:97:9`!; |
| 265 | } |
| 266 | |
| 267 | |
| 268 | ////////////////////////////////////////////////////////////////////////// |
| 269 | // Memory Allocation |
| 270 | |
| 271 | MODCOMMANDcxx . . $ MODCOMMAND# *CSoundFilecxx . . $ CSoundFile#::AllocatePatterncxx . . $ CSoundFile#AllocatePattern(697652e068d7f138).(UINTcxx . . $ UINT# rows, UINTcxx . . $ UINT# nchns) |
| 272 | //------------------------------------------------------------ |
| 273 | { |
| 274 | MODCOMMANDcxx . . $ MODCOMMAND# *p = new MODCOMMANDcxx . . $ MODCOMMAND#[rows*nchns]; |
| 275 | if (p) memset(p, 0, rows*nchns*sizeof(MODCOMMANDcxx . . $ MODCOMMAND#)); |
| 276 | return p; |
| 277 | } |
| 278 | |
| 279 | |
| 280 | void CSoundFilecxx . . $ CSoundFile#::FreePatterncxx . . $ CSoundFile#FreePattern(5d22bdacc48458e8).(LPVOIDcxx . . $ LPVOID# pat) |
| 281 | //-------------------------------------- |
| 282 | { |
| 283 | if (pat) delete [] (signed char*)pat; |
| 284 | } |
| 285 | |
| 286 | |
| 287 | signed char* CSoundFilecxx . . $ CSoundFile#::AllocateSamplecxx . . $ CSoundFile#AllocateSample(f3169d5868adb627).(UINTcxx . . $ UINT# nbytes) |
| 288 | //------------------------------------------- |
| 289 | { |
| 290 | signed char * p = (signed char *)GlobalAllocPtrcxx . . $ GlobalAllocPtr(337445495618d213).(GHNDcxx . . $ `ext/psmplug/stdafx.h:82:10`!, (nbytes+39) & ~7); |
| 291 | if (p) p += 16; |
| 292 | return p; |
| 293 | } |
| 294 | |
| 295 | |
| 296 | void CSoundFilecxx . . $ CSoundFile#::FreeSamplecxx . . $ CSoundFile#FreeSample(5d22bdacc48458e8).(LPVOIDcxx . . $ LPVOID# p) |
| 297 | //----------------------------------- |
| 298 | { |
| 299 | if (p) |
| 300 | { |
| 301 | GlobalFreePtrcxx . . $ `ext/psmplug/stdafx.h:83:9`!(((LPSTR)p)-16); |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | |
| 306 | ////////////////////////////////////////////////////////////////////////// |
| 307 | // Misc functions |
| 308 | |
| 309 | void CSoundFilecxx . . $ CSoundFile#::ResetMidiCfgcxx . . $ CSoundFile#ResetMidiCfg(49f6e7a06ebc5aa8).() |
| 310 | //----------------------------- |
| 311 | { |
| 312 | memset(&m_MidiCfgcxx . . $ CSoundFile#m_MidiCfg., 0, sizeof(m_MidiCfgcxx . . $ CSoundFile#m_MidiCfg.)); |
| 313 | lstrcpyAcxx . . $ `ext/psmplug/stdafx.h:77:9`!(&m_MidiCfgcxx . . $ CSoundFile#m_MidiCfg..szMidiGlbcxx . . $ MODMIDICFG#szMidiGlb.[MIDIOUT_STARTcxx . . $ MIDIOUT_START.*32], "FF"); |
| 314 | lstrcpyAcxx . . $ `ext/psmplug/stdafx.h:77:9`!(&m_MidiCfgcxx . . $ CSoundFile#m_MidiCfg..szMidiGlbcxx . . $ MODMIDICFG#szMidiGlb.[MIDIOUT_STOPcxx . . $ MIDIOUT_STOP.*32], "FC"); |
| 315 | lstrcpyAcxx . . $ `ext/psmplug/stdafx.h:77:9`!(&m_MidiCfgcxx . . $ CSoundFile#m_MidiCfg..szMidiGlbcxx . . $ MODMIDICFG#szMidiGlb.[MIDIOUT_NOTEONcxx . . $ MIDIOUT_NOTEON.*32], "9c n v"); |
| 316 | lstrcpyAcxx . . $ `ext/psmplug/stdafx.h:77:9`!(&m_MidiCfgcxx . . $ CSoundFile#m_MidiCfg..szMidiGlbcxx . . $ MODMIDICFG#szMidiGlb.[MIDIOUT_NOTEOFFcxx . . $ MIDIOUT_NOTEOFF.*32], "9c n 0"); |
| 317 | lstrcpyAcxx . . $ `ext/psmplug/stdafx.h:77:9`!(&m_MidiCfgcxx . . $ CSoundFile#m_MidiCfg..szMidiGlbcxx . . $ MODMIDICFG#szMidiGlb.[MIDIOUT_PROGRAMcxx . . $ MIDIOUT_PROGRAM.*32], "Cc p"); |
| 318 | lstrcpyAcxx . . $ `ext/psmplug/stdafx.h:77:9`!(&m_MidiCfgcxx . . $ CSoundFile#m_MidiCfg..szMidiSFXExtcxx . . $ MODMIDICFG#szMidiSFXExt.[0], "F0F000z"); |
| 319 | for (int iz=0; iz<16; iz++) wsprintfAcxx . . $ `ext/psmplug/stdafx.h:78:9`!(&m_MidiCfgcxx . . $ CSoundFile#m_MidiCfg..szMidiZXXExtcxx . . $ MODMIDICFG#szMidiZXXExt.[iz*32], "F0F001%02X", iz*8); |
| 320 | } |
| 321 | |
| 322 | |
| 323 | UINTcxx . . $ UINT# CSoundFilecxx . . $ CSoundFile#::GetNumChannelscxx . . $ CSoundFile#GetNumChannels(ddd8539a2fcdd4ce).() const |
| 324 | //------------------------------------- |
| 325 | { |
| 326 | UINTcxx . . $ UINT# n = 0; |
| 327 | for (UINTcxx . . $ UINT# i=0; i<m_nChannelscxx . . $ CSoundFile#m_nChannels.; i++) if (ChnSettingscxx . . $ CSoundFile#ChnSettings.[i].nVolumecxx . . $ _MODCHANNELSETTINGS#nVolume.) n++; |
| 328 | return n; |
| 329 | } |
| 330 | |
| 331 | |
| 332 | UINTcxx . . $ UINT# CSoundFilecxx . . $ CSoundFile#::GetSongCommentscxx . . $ CSoundFile#GetSongComments(968bca23ac7df750).(LPSTRcxx . . $ LPSTR# s, UINTcxx . . $ UINT# len, UINTcxx . . $ UINT# linesize) |
| 333 | //---------------------------------------------------------------- |
| 334 | { |
| 335 | LPCSTRcxx . . $ LPCSTR# p = m_lpszSongCommentscxx . . $ CSoundFile#m_lpszSongComments.; |
| 336 | if (!p) return 0; |
| 337 | UINTcxx . . $ UINT# i = 2, ln=0; |
| 338 | if ((len) && (s)) s[0] = '\x0D'; |
| 339 | if ((len > 1) && (s)) s[1] = '\x0A'; |
| 340 | while ((*p) && (i+2 < len)) |
| 341 | { |
| 342 | BYTEcxx . . $ BYTE# c = (BYTEcxx . . $ BYTE#)*p++; |
| 343 | if ((c == 0x0D) || ((c == ' ') && (ln >= linesize))) |
| 344 | { if (s) { s[i++] = '\x0D'; s[i++] = '\x0A'; } else i+= 2; ln=0; } |
| 345 | else |
| 346 | if (c >= 0x20) { if (s) s[i++] = c; else i++; ln++; } |
| 347 | } |
| 348 | if (s) s[i] = 0; |
| 349 | return i; |
| 350 | } |
| 351 | |
| 352 | |
| 353 | UINTcxx . . $ UINT# CSoundFilecxx . . $ CSoundFile#::GetRawSongCommentscxx . . $ CSoundFile#GetRawSongComments(968bca23ac7df750).(LPSTRcxx . . $ LPSTR# s, UINTcxx . . $ UINT# len, UINTcxx . . $ UINT# linesize) |
| 354 | //------------------------------------------------------------------- |
| 355 | { |
| 356 | LPCSTRcxx . . $ LPCSTR# p = m_lpszSongCommentscxx . . $ CSoundFile#m_lpszSongComments.; |
| 357 | if (!p) return 0; |
| 358 | UINTcxx . . $ UINT# i = 0, ln=0; |
| 359 | while ((*p) && (i < len-1)) |
| 360 | { |
| 361 | BYTEcxx . . $ BYTE# c = (BYTEcxx . . $ BYTE#)*p++; |
| 362 | if ((c == 0x0D) || (c == 0x0A)) |
| 363 | { |
| 364 | if (ln) |
| 365 | { |
| 366 | while (ln < linesize) { if (s) s[i] = ' '; i++; ln++; } |
| 367 | ln = 0; |
| 368 | } |
| 369 | } else |
| 370 | if ((c == ' ') && (!ln)) |
| 371 | { |
| 372 | UINTcxx . . $ UINT# k=0; |
| 373 | while ((p[k]) && (p[k] >= ' ')) k++; |
| 374 | if (k <= linesize) |
| 375 | { |
| 376 | if (s) s[i] = ' '; |
| 377 | i++; |
| 378 | ln++; |
| 379 | } |
| 380 | } else |
| 381 | { |
| 382 | if (s) s[i] = c; |
| 383 | i++; |
| 384 | ln++; |
| 385 | if (ln == linesize) ln = 0; |
| 386 | } |
| 387 | } |
| 388 | if (ln) |
| 389 | { |
| 390 | while ((ln < linesize) && (i < len)) |
| 391 | { |
| 392 | if (s) s[i] = ' '; |
| 393 | i++; |
| 394 | ln++; |
| 395 | } |
| 396 | } |
| 397 | if (s) s[i] = 0; |
| 398 | return i; |
| 399 | } |
| 400 | |
| 401 | |
| 402 | BOOLcxx . . $ BOOL# CSoundFilecxx . . $ CSoundFile#::SetWaveConfigcxx . . $ CSoundFile#SetWaveConfig(ba40b00a3e4c32e8).(UINTcxx . . $ UINT# nRate,UINTcxx . . $ UINT# nBits,UINTcxx . . $ UINT# nChannels,BOOLcxx . . $ BOOL# bMMX) |
| 403 | //---------------------------------------------------------------------------- |
| 404 | { |
| 405 | BOOLcxx . . $ BOOL# bReset = FALSEcxx . . $ `ext/psmplug/stdafx.h:93:9`!; |
| 406 | DWORDcxx . . $ DWORD# d = gdwSoundSetupcxx . . $ CSoundFile#gdwSoundSetup. & ~SNDMIX_ENABLEMMXcxx . . $ `ext/psmplug/sndfile.h:269:9`!; |
| 407 | if (bMMX) d |= SNDMIX_ENABLEMMXcxx . . $ `ext/psmplug/sndfile.h:269:9`!; |
| 408 | if ((gdwMixingFreqcxx . . $ CSoundFile#gdwMixingFreq. != nRate) || (gnBitsPerSamplecxx . . $ CSoundFile#gnBitsPerSample. != nBits) || (gnChannelscxx . . $ CSoundFile#gnChannels. != nChannels) || (d != gdwSoundSetupcxx . . $ CSoundFile#gdwSoundSetup.)) bReset = TRUEcxx . . $ `ext/psmplug/stdafx.h:97:9`!; |
| 409 | gnChannelscxx . . $ CSoundFile#gnChannels. = nChannels; |
| 410 | gdwSoundSetupcxx . . $ CSoundFile#gdwSoundSetup. = d; |
| 411 | gdwMixingFreqcxx . . $ CSoundFile#gdwMixingFreq. = nRate; |
| 412 | gnBitsPerSamplecxx . . $ CSoundFile#gnBitsPerSample. = nBits; |
| 413 | InitPlayercxx . . $ CSoundFile#InitPlayer(efaadfb7dc14930a).(bReset); |
| 414 | return TRUEcxx . . $ `ext/psmplug/stdafx.h:97:9`!; |
| 415 | } |
| 416 | |
| 417 | BOOLcxx . . $ BOOL# CSoundFilecxx . . $ CSoundFile#::SetMixConfigcxx . . $ CSoundFile#SetMixConfig(8e1b545ea3aecce3).(UINTcxx . . $ UINT# nStereoSeparation, UINTcxx . . $ UINT# nMaxMixChannels) |
| 418 | //------------------------------------------------------------------------- |
| 419 | { |
| 420 | if (nMaxMixChannels < 2) return FALSEcxx . . $ `ext/psmplug/stdafx.h:93:9`!; |
| 421 | |
| 422 | m_nMaxMixChannelscxx . . $ CSoundFile#m_nMaxMixChannels. = nMaxMixChannels; |
| 423 | m_nStereoSeparationcxx . . $ CSoundFile#m_nStereoSeparation. = nStereoSeparation; |
| 424 | return TRUEcxx . . $ `ext/psmplug/stdafx.h:97:9`!; |
| 425 | } |
| 426 | |
| 427 | |
| 428 | BOOLcxx . . $ BOOL# CSoundFilecxx . . $ CSoundFile#::SetResamplingModecxx . . $ CSoundFile#SetResamplingMode(dfa6e707f7696010).(UINTcxx . . $ UINT# nMode) |
| 429 | //-------------------------------------------- |
| 430 | { |
| 431 | DWORDcxx . . $ DWORD# d = gdwSoundSetupcxx . . $ CSoundFile#gdwSoundSetup. & ~(SNDMIX_NORESAMPLINGcxx . . $ `ext/psmplug/sndfile.h:259:9`!|SNDMIX_HQRESAMPLERcxx . . $ `ext/psmplug/sndfile.h:260:9`!|SNDMIX_ULTRAHQSRCMODEcxx . . $ `ext/psmplug/sndfile.h:266:9`!); |
| 432 | switch(nMode) |
| 433 | { |
| 434 | case SRCMODE_NEARESTcxx . . $ SRCMODE_NEAREST.: d |= SNDMIX_NORESAMPLINGcxx . . $ `ext/psmplug/sndfile.h:259:9`!; break; |
| 435 | case SRCMODE_LINEARcxx . . $ SRCMODE_LINEAR.: break; |
| 436 | case SRCMODE_SPLINEcxx . . $ SRCMODE_SPLINE.: d |= SNDMIX_HQRESAMPLERcxx . . $ `ext/psmplug/sndfile.h:260:9`!; break; |
| 437 | case SRCMODE_POLYPHASEcxx . . $ SRCMODE_POLYPHASE.: d |= (SNDMIX_HQRESAMPLERcxx . . $ `ext/psmplug/sndfile.h:260:9`!|SNDMIX_ULTRAHQSRCMODEcxx . . $ `ext/psmplug/sndfile.h:266:9`!); break; |
| 438 | default: |
| 439 | return FALSEcxx . . $ `ext/psmplug/stdafx.h:93:9`!; |
| 440 | } |
| 441 | gdwSoundSetupcxx . . $ CSoundFile#gdwSoundSetup. = d; |
| 442 | return TRUEcxx . . $ `ext/psmplug/stdafx.h:97:9`!; |
| 443 | } |
| 444 | |
| 445 | |
| 446 | BOOLcxx . . $ BOOL# CSoundFilecxx . . $ CSoundFile#::SetMasterVolumecxx . . $ CSoundFile#SetMasterVolume(f97cc7cf123a0aff).(UINTcxx . . $ UINT# nVol, BOOLcxx . . $ BOOL# bAdjustAGC) |
| 447 | //---------------------------------------------------------- |
| 448 | { |
| 449 | if (nVol < 1) nVol = 1; |
| 450 | if (nVol > 0x200) nVol = 0x200; // x4 maximum |
| 451 | if ((nVol < m_nMasterVolumecxx . . $ CSoundFile#m_nMasterVolume.) && (nVol) && (gdwSoundSetupcxx . . $ CSoundFile#gdwSoundSetup. & SNDMIX_AGCcxx . . $ `ext/psmplug/sndfile.h:258:9`!) && (bAdjustAGC)) |
| 452 | { |
| 453 | gnAGCcxx . . $ CSoundFile#gnAGC. = gnAGCcxx . . $ CSoundFile#gnAGC. * m_nMasterVolumecxx . . $ CSoundFile#m_nMasterVolume. / nVol; |
| 454 | if (gnAGCcxx . . $ CSoundFile#gnAGC. > AGC_UNITYcxx . . $ `ext/psmplug/sndfile.h:892:9`!) gnAGCcxx . . $ CSoundFile#gnAGC. = AGC_UNITYcxx . . $ `ext/psmplug/sndfile.h:892:9`!; |
| 455 | } |
| 456 | m_nMasterVolumecxx . . $ CSoundFile#m_nMasterVolume. = nVol; |
| 457 | return TRUEcxx . . $ `ext/psmplug/stdafx.h:97:9`!; |
| 458 | } |
| 459 | |
| 460 | BOOLcxx . . $ BOOL# CSoundFilecxx . . $ CSoundFile#::SetTempoFactorcxx . . $ CSoundFile#SetTempoFactor(dfa6e707f7696010).(UINTcxx . . $ UINT# nTemp) |
| 461 | //---------------------------------------------------------- |
| 462 | { |
| 463 | if (nTemp < 1) nTemp = 1; |
| 464 | if (nTemp > 0x100) nTemp = 0x100; |
| 465 | |
| 466 | m_nTempoFactorcxx . . $ CSoundFile#m_nTempoFactor. = nTemp; |
| 467 | |
| 468 | return TRUEcxx . . $ `ext/psmplug/stdafx.h:97:9`!; |
| 469 | } |
| 470 | |
| 471 | UINTcxx . . $ UINT# CSoundFilecxx . . $ CSoundFile#::GetNumPatternscxx . . $ CSoundFile#GetNumPatterns(ddd8539a2fcdd4ce).() const |
| 472 | //------------------------------------- |
| 473 | { |
| 474 | UINTcxx . . $ UINT# i = 0; |
| 475 | while ((i < MAX_ORDERScxx . . $ `ext/psmplug/sndfile.h:23:9`!) && (Ordercxx . . $ CSoundFile#Order.[i] < 0xFF)) i++; |
| 476 | return i; |
| 477 | } |
| 478 | |
| 479 | |
| 480 | UINTcxx . . $ UINT# CSoundFilecxx . . $ CSoundFile#::GetNumInstrumentscxx . . $ CSoundFile#GetNumInstruments(ddd8539a2fcdd4ce).() const |
| 481 | //---------------------------------------- |
| 482 | { |
| 483 | UINTcxx . . $ UINT# n=0; |
| 484 | for (UINTcxx . . $ UINT# i=0; i<MAX_INSTRUMENTScxx . . $ `ext/psmplug/sndfile.h:26:9`!; i++) if (Inscxx . . $ CSoundFile#Ins.[i].pSamplecxx . . $ _MODINSTRUMENT#pSample.) n++; |
| 485 | return n; |
| 486 | } |
| 487 | |
| 488 | |
| 489 | UINTcxx . . $ UINT# CSoundFilecxx . . $ CSoundFile#::GetMaxPositioncxx . . $ CSoundFile#GetMaxPosition(ddd8539a2fcdd4ce).() const |
| 490 | //------------------------------------- |
| 491 | { |
| 492 | UINTcxx . . $ UINT# max = 0; |
| 493 | UINTcxx . . $ UINT# i = 0; |
| 494 | |
| 495 | while ((i < MAX_ORDERScxx . . $ `ext/psmplug/sndfile.h:23:9`!) && (Ordercxx . . $ CSoundFile#Order.[i] != 0xFF)) |
| 496 | { |
| 497 | if (Ordercxx . . $ CSoundFile#Order.[i] < MAX_PATTERNScxx . . $ `ext/psmplug/sndfile.h:24:9`!) max += PatternSizecxx . . $ CSoundFile#PatternSize.[Ordercxx . . $ CSoundFile#Order.[i]]; |
| 498 | i++; |
| 499 | } |
| 500 | return max; |
| 501 | } |
| 502 | |
| 503 | |
| 504 | UINTcxx . . $ UINT# CSoundFilecxx . . $ CSoundFile#::GetCurrentPoscxx . . $ CSoundFile#GetCurrentPos(ddd8539a2fcdd4ce).() const |
| 505 | //------------------------------------ |
| 506 | { |
| 507 | UINTcxx . . $ UINT# pos = 0; |
| 508 | |
| 509 | for (UINTcxx . . $ UINT# i=0; i<m_nCurrentPatterncxx . . $ CSoundFile#m_nCurrentPattern.; i++) if (Ordercxx . . $ CSoundFile#Order.[i] < MAX_PATTERNScxx . . $ `ext/psmplug/sndfile.h:24:9`!) |
| 510 | pos += PatternSizecxx . . $ CSoundFile#PatternSize.[Ordercxx . . $ CSoundFile#Order.[i]]; |
| 511 | return pos + m_nRowcxx . . $ CSoundFile#m_nRow.; |
| 512 | } |
| 513 | |
| 514 | |
| 515 | void CSoundFilecxx . . $ CSoundFile#::SetCurrentPoscxx . . $ CSoundFile#SetCurrentPos(cb2f890c2fdad230).(UINTcxx . . $ UINT# nPos) |
| 516 | //--------------------------------------- |
| 517 | { |
| 518 | UINTcxx . . $ UINT# i, nPattern; |
| 519 | |
| 520 | for (i=0; i<MAX_CHANNELScxx . . $ `ext/psmplug/sndfile.h:27:9`!; i++) |
| 521 | { |
| 522 | Chncxx . . $ CSoundFile#Chn.[i].nNotecxx . . $ _MODCHANNEL#nNote. = Chncxx . . $ CSoundFile#Chn.[i].nNewNotecxx . . $ _MODCHANNEL#nNewNote. = Chncxx . . $ CSoundFile#Chn.[i].nNewInscxx . . $ _MODCHANNEL#nNewIns. = 0; |
| 523 | Chncxx . . $ CSoundFile#Chn.[i].pInstrumentcxx . . $ _MODCHANNEL#pInstrument. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 524 | Chncxx . . $ CSoundFile#Chn.[i].pHeadercxx . . $ _MODCHANNEL#pHeader. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 525 | Chncxx . . $ CSoundFile#Chn.[i].nPortamentoDestcxx . . $ _MODCHANNEL#nPortamentoDest. = 0; |
| 526 | Chncxx . . $ CSoundFile#Chn.[i].nCommandcxx . . $ _MODCHANNEL#nCommand. = 0; |
| 527 | Chncxx . . $ CSoundFile#Chn.[i].nPatternLoopCountcxx . . $ _MODCHANNEL#nPatternLoopCount. = 0; |
| 528 | Chncxx . . $ CSoundFile#Chn.[i].nPatternLoopcxx . . $ _MODCHANNEL#nPatternLoop. = 0; |
| 529 | Chncxx . . $ CSoundFile#Chn.[i].nFadeOutVolcxx . . $ _MODCHANNEL#nFadeOutVol. = 0; |
| 530 | Chncxx . . $ CSoundFile#Chn.[i].dwFlagscxx . . $ _MODCHANNEL#dwFlags. |= CHN_KEYOFFcxx . . $ `ext/psmplug/sndfile.h:83:9`!|CHN_NOTEFADEcxx . . $ `ext/psmplug/sndfile.h:84:9`!; |
| 531 | Chncxx . . $ CSoundFile#Chn.[i].nTremorCountcxx . . $ _MODCHANNEL#nTremorCount. = 0; |
| 532 | } |
| 533 | if (!nPos) |
| 534 | { |
| 535 | for (i=0; i<MAX_CHANNELScxx . . $ `ext/psmplug/sndfile.h:27:9`!; i++) |
| 536 | { |
| 537 | Chncxx . . $ CSoundFile#Chn.[i].nPeriodcxx . . $ _MODCHANNEL#nPeriod. = 0; |
| 538 | Chncxx . . $ CSoundFile#Chn.[i].nPoscxx . . $ _MODCHANNEL#nPos. = Chncxx . . $ CSoundFile#Chn.[i].nLengthcxx . . $ _MODCHANNEL#nLength. = 0; |
| 539 | Chncxx . . $ CSoundFile#Chn.[i].nLoopStartcxx . . $ _MODCHANNEL#nLoopStart. = 0; |
| 540 | Chncxx . . $ CSoundFile#Chn.[i].nLoopEndcxx . . $ _MODCHANNEL#nLoopEnd. = 0; |
| 541 | Chncxx . . $ CSoundFile#Chn.[i].nROfscxx . . $ _MODCHANNEL#nROfs. = Chncxx . . $ CSoundFile#Chn.[i].nLOfscxx . . $ _MODCHANNEL#nLOfs. = 0; |
| 542 | Chncxx . . $ CSoundFile#Chn.[i].pSamplecxx . . $ _MODCHANNEL#pSample. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 543 | Chncxx . . $ CSoundFile#Chn.[i].pInstrumentcxx . . $ _MODCHANNEL#pInstrument. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 544 | Chncxx . . $ CSoundFile#Chn.[i].pHeadercxx . . $ _MODCHANNEL#pHeader. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 545 | Chncxx . . $ CSoundFile#Chn.[i].nCutOffcxx . . $ _MODCHANNEL#nCutOff. = 0x7F; |
| 546 | Chncxx . . $ CSoundFile#Chn.[i].nResonancecxx . . $ _MODCHANNEL#nResonance. = 0; |
| 547 | Chncxx . . $ CSoundFile#Chn.[i].nLeftVolcxx . . $ _MODCHANNEL#nLeftVol. = Chncxx . . $ CSoundFile#Chn.[i].nRightVolcxx . . $ _MODCHANNEL#nRightVol. = 0; |
| 548 | Chncxx . . $ CSoundFile#Chn.[i].nNewLeftVolcxx . . $ _MODCHANNEL#nNewLeftVol. = Chncxx . . $ CSoundFile#Chn.[i].nNewRightVolcxx . . $ _MODCHANNEL#nNewRightVol. = 0; |
| 549 | Chncxx . . $ CSoundFile#Chn.[i].nLeftRampcxx . . $ _MODCHANNEL#nLeftRamp. = Chncxx . . $ CSoundFile#Chn.[i].nRightRampcxx . . $ _MODCHANNEL#nRightRamp. = 0; |
| 550 | Chncxx . . $ CSoundFile#Chn.[i].nVolumecxx . . $ _MODCHANNEL#nVolume. = 256; |
| 551 | if (i < MAX_BASECHANNELScxx . . $ `ext/psmplug/sndfile.h:28:9`!) |
| 552 | { |
| 553 | Chncxx . . $ CSoundFile#Chn.[i].dwFlagscxx . . $ _MODCHANNEL#dwFlags. = ChnSettingscxx . . $ CSoundFile#ChnSettings.[i].dwFlagscxx . . $ _MODCHANNELSETTINGS#dwFlags.; |
| 554 | Chncxx . . $ CSoundFile#Chn.[i].nPancxx . . $ _MODCHANNEL#nPan. = ChnSettingscxx . . $ CSoundFile#ChnSettings.[i].nPancxx . . $ _MODCHANNELSETTINGS#nPan.; |
| 555 | Chncxx . . $ CSoundFile#Chn.[i].nGlobalVolcxx . . $ _MODCHANNEL#nGlobalVol. = ChnSettingscxx . . $ CSoundFile#ChnSettings.[i].nVolumecxx . . $ _MODCHANNELSETTINGS#nVolume.; |
| 556 | } else |
| 557 | { |
| 558 | Chncxx . . $ CSoundFile#Chn.[i].dwFlagscxx . . $ _MODCHANNEL#dwFlags. = 0; |
| 559 | Chncxx . . $ CSoundFile#Chn.[i].nPancxx . . $ _MODCHANNEL#nPan. = 128; |
| 560 | Chncxx . . $ CSoundFile#Chn.[i].nGlobalVolcxx . . $ _MODCHANNEL#nGlobalVol. = 64; |
| 561 | } |
| 562 | } |
| 563 | m_nGlobalVolumecxx . . $ CSoundFile#m_nGlobalVolume. = m_nDefaultGlobalVolumecxx . . $ CSoundFile#m_nDefaultGlobalVolume.; |
| 564 | m_nMusicSpeedcxx . . $ CSoundFile#m_nMusicSpeed. = m_nDefaultSpeedcxx . . $ CSoundFile#m_nDefaultSpeed.; |
| 565 | m_nMusicTempocxx . . $ CSoundFile#m_nMusicTempo. = m_nDefaultTempocxx . . $ CSoundFile#m_nDefaultTempo.; |
| 566 | } |
| 567 | m_dwSongFlagscxx . . $ CSoundFile#m_dwSongFlags. &= ~(SONG_PATTERNLOOPcxx . . $ `ext/psmplug/sndfile.h:242:9`!|SONG_CPUVERYHIGHcxx . . $ `ext/psmplug/sndfile.h:248:9`!|SONG_FADINGSONGcxx . . $ `ext/psmplug/sndfile.h:245:9`!|SONG_ENDREACHEDcxx . . $ `ext/psmplug/sndfile.h:246:9`!|SONG_GLOBALFADEcxx . . $ `ext/psmplug/sndfile.h:247:9`!); |
| 568 | for (nPattern = 0; nPattern < MAX_ORDERScxx . . $ `ext/psmplug/sndfile.h:23:9`!; nPattern++) |
| 569 | { |
| 570 | UINTcxx . . $ UINT# ord = Ordercxx . . $ CSoundFile#Order.[nPattern]; |
| 571 | if (ord == 0xFE) continue; |
| 572 | if (ord == 0xFF) break; |
| 573 | if (ord < MAX_PATTERNScxx . . $ `ext/psmplug/sndfile.h:24:9`!) |
| 574 | { |
| 575 | if (nPos < (UINTcxx . . $ UINT#)PatternSizecxx . . $ CSoundFile#PatternSize.[ord]) break; |
| 576 | nPos -= PatternSizecxx . . $ CSoundFile#PatternSize.[ord]; |
| 577 | } |
| 578 | } |
| 579 | // Buggy position ? |
| 580 | if ((nPattern >= MAX_ORDERScxx . . $ `ext/psmplug/sndfile.h:23:9`!) |
| 581 | || (Ordercxx . . $ CSoundFile#Order.[nPattern] >= MAX_PATTERNScxx . . $ `ext/psmplug/sndfile.h:24:9`!) |
| 582 | || (nPos >= PatternSizecxx . . $ CSoundFile#PatternSize.[Ordercxx . . $ CSoundFile#Order.[nPattern]])) |
| 583 | { |
| 584 | nPos = 0; |
| 585 | nPattern = 0; |
| 586 | } |
| 587 | UINTcxx . . $ UINT# nRow = nPos; |
| 588 | if ((nRow) && (Ordercxx . . $ CSoundFile#Order.[nPattern] < MAX_PATTERNScxx . . $ `ext/psmplug/sndfile.h:24:9`!)) |
| 589 | { |
| 590 | MODCOMMANDcxx . . $ MODCOMMAND# *p = Patternscxx . . $ CSoundFile#Patterns.[Ordercxx . . $ CSoundFile#Order.[nPattern]]; |
| 591 | if ((p) && (nRow < PatternSizecxx . . $ CSoundFile#PatternSize.[Ordercxx . . $ CSoundFile#Order.[nPattern]])) |
| 592 | { |
| 593 | BOOLcxx . . $ BOOL# bOk = FALSEcxx . . $ `ext/psmplug/stdafx.h:93:9`!; |
| 594 | while ((!bOk) && (nRow > 0)) |
| 595 | { |
| 596 | UINTcxx . . $ UINT# n = nRow * m_nChannelscxx . . $ CSoundFile#m_nChannels.; |
| 597 | for (UINTcxx . . $ UINT# k=0; k<m_nChannelscxx . . $ CSoundFile#m_nChannels.; k++, n++) |
| 598 | { |
| 599 | if (p[n].notecxx . . $ _MODCOMMAND#note.) |
| 600 | { |
| 601 | bOk = TRUEcxx . . $ `ext/psmplug/stdafx.h:97:9`!; |
| 602 | break; |
| 603 | } |
| 604 | } |
| 605 | if (!bOk) nRow--; |
| 606 | } |
| 607 | } |
| 608 | } |
| 609 | m_nNextPatterncxx . . $ CSoundFile#m_nNextPattern. = nPattern; |
| 610 | m_nNextRowcxx . . $ CSoundFile#m_nNextRow. = nRow; |
| 611 | m_nNextStartRowcxx . . $ CSoundFile#m_nNextStartRow. = 0; |
| 612 | m_nTickCountcxx . . $ CSoundFile#m_nTickCount. = m_nMusicSpeedcxx . . $ CSoundFile#m_nMusicSpeed.; |
| 613 | m_nBufferCountcxx . . $ CSoundFile#m_nBufferCount. = 0; |
| 614 | m_nPatternDelaycxx . . $ CSoundFile#m_nPatternDelay. = 0; |
| 615 | m_nFrameDelaycxx . . $ CSoundFile#m_nFrameDelay. = 0; |
| 616 | } |
| 617 | |
| 618 | |
| 619 | void CSoundFilecxx . . $ CSoundFile#::SetCurrentOrdercxx . . $ CSoundFile#SetCurrentOrder(cb2f890c2fdad230).(UINTcxx . . $ UINT# nPos) |
| 620 | //----------------------------------------- |
| 621 | { |
| 622 | while ((nPos < MAX_ORDERScxx . . $ `ext/psmplug/sndfile.h:23:9`!) && (Ordercxx . . $ CSoundFile#Order.[nPos] == 0xFE)) nPos++; |
| 623 | if ((nPos >= MAX_ORDERScxx . . $ `ext/psmplug/sndfile.h:23:9`!) || (Ordercxx . . $ CSoundFile#Order.[nPos] >= MAX_PATTERNScxx . . $ `ext/psmplug/sndfile.h:24:9`!)) return; |
| 624 | for (UINTcxx . . $ UINT# j=0; j<MAX_CHANNELScxx . . $ `ext/psmplug/sndfile.h:27:9`!; j++) |
| 625 | { |
| 626 | Chncxx . . $ CSoundFile#Chn.[j].nPeriodcxx . . $ _MODCHANNEL#nPeriod. = 0; |
| 627 | Chncxx . . $ CSoundFile#Chn.[j].nNotecxx . . $ _MODCHANNEL#nNote. = 0; |
| 628 | Chncxx . . $ CSoundFile#Chn.[j].nPortamentoDestcxx . . $ _MODCHANNEL#nPortamentoDest. = 0; |
| 629 | Chncxx . . $ CSoundFile#Chn.[j].nCommandcxx . . $ _MODCHANNEL#nCommand. = 0; |
| 630 | Chncxx . . $ CSoundFile#Chn.[j].nPatternLoopCountcxx . . $ _MODCHANNEL#nPatternLoopCount. = 0; |
| 631 | Chncxx . . $ CSoundFile#Chn.[j].nPatternLoopcxx . . $ _MODCHANNEL#nPatternLoop. = 0; |
| 632 | Chncxx . . $ CSoundFile#Chn.[j].nTremorCountcxx . . $ _MODCHANNEL#nTremorCount. = 0; |
| 633 | } |
| 634 | if (!nPos) |
| 635 | { |
| 636 | SetCurrentPoscxx . . $ CSoundFile#SetCurrentPos(cb2f890c2fdad230).(0); |
| 637 | } else |
| 638 | { |
| 639 | m_nNextPatterncxx . . $ CSoundFile#m_nNextPattern. = nPos; |
| 640 | m_nRowcxx . . $ CSoundFile#m_nRow. = m_nNextRowcxx . . $ CSoundFile#m_nNextRow. = m_nNextStartRowcxx . . $ CSoundFile#m_nNextStartRow. = 0; |
| 641 | m_nPatterncxx . . $ CSoundFile#m_nPattern. = 0; |
| 642 | m_nTickCountcxx . . $ CSoundFile#m_nTickCount. = m_nMusicSpeedcxx . . $ CSoundFile#m_nMusicSpeed.; |
| 643 | m_nBufferCountcxx . . $ CSoundFile#m_nBufferCount. = 0; |
| 644 | m_nTotalCountcxx . . $ CSoundFile#m_nTotalCount. = 0; |
| 645 | m_nPatternDelaycxx . . $ CSoundFile#m_nPatternDelay. = 0; |
| 646 | m_nFrameDelaycxx . . $ CSoundFile#m_nFrameDelay. = 0; |
| 647 | } |
| 648 | m_dwSongFlagscxx . . $ CSoundFile#m_dwSongFlags. &= ~(SONG_PATTERNLOOPcxx . . $ `ext/psmplug/sndfile.h:242:9`!|SONG_CPUVERYHIGHcxx . . $ `ext/psmplug/sndfile.h:248:9`!|SONG_FADINGSONGcxx . . $ `ext/psmplug/sndfile.h:245:9`!|SONG_ENDREACHEDcxx . . $ `ext/psmplug/sndfile.h:246:9`!|SONG_GLOBALFADEcxx . . $ `ext/psmplug/sndfile.h:247:9`!); |
| 649 | } |
| 650 | |
| 651 | |
| 652 | void CSoundFilecxx . . $ CSoundFile#::ResetChannelscxx . . $ CSoundFile#ResetChannels(49f6e7a06ebc5aa8).() |
| 653 | //------------------------------ |
| 654 | { |
| 655 | m_dwSongFlagscxx . . $ CSoundFile#m_dwSongFlags. &= ~(SONG_CPUVERYHIGHcxx . . $ `ext/psmplug/sndfile.h:248:9`!|SONG_FADINGSONGcxx . . $ `ext/psmplug/sndfile.h:245:9`!|SONG_ENDREACHEDcxx . . $ `ext/psmplug/sndfile.h:246:9`!|SONG_GLOBALFADEcxx . . $ `ext/psmplug/sndfile.h:247:9`!); |
| 656 | m_nBufferCountcxx . . $ CSoundFile#m_nBufferCount. = 0; |
| 657 | for (UINTcxx . . $ UINT# i=0; i<MAX_CHANNELScxx . . $ `ext/psmplug/sndfile.h:27:9`!; i++) |
| 658 | { |
| 659 | Chncxx . . $ CSoundFile#Chn.[i].nROfscxx . . $ _MODCHANNEL#nROfs. = Chncxx . . $ CSoundFile#Chn.[i].nLOfscxx . . $ _MODCHANNEL#nLOfs. = 0; |
| 660 | } |
| 661 | } |
| 662 | |
| 663 | |
| 664 | void CSoundFilecxx . . $ CSoundFile#::LoopPatterncxx . . $ CSoundFile#LoopPattern(3e454b8ccf442868).(int nPat, int nRow) |
| 665 | //---------------------------------------------- |
| 666 | { |
| 667 | if ((nPat < 0) || (nPat >= MAX_PATTERNScxx . . $ `ext/psmplug/sndfile.h:24:9`!) || (!Patternscxx . . $ CSoundFile#Patterns.[nPat])) |
| 668 | { |
| 669 | m_dwSongFlagscxx . . $ CSoundFile#m_dwSongFlags. &= ~SONG_PATTERNLOOPcxx . . $ `ext/psmplug/sndfile.h:242:9`!; |
| 670 | } else |
| 671 | { |
| 672 | if ((nRow < 0) || (nRow >= PatternSizecxx . . $ CSoundFile#PatternSize.[nPat])) nRow = 0; |
| 673 | m_nPatterncxx . . $ CSoundFile#m_nPattern. = nPat; |
| 674 | m_nRowcxx . . $ CSoundFile#m_nRow. = m_nNextRowcxx . . $ CSoundFile#m_nNextRow. = nRow; |
| 675 | m_nTickCountcxx . . $ CSoundFile#m_nTickCount. = m_nMusicSpeedcxx . . $ CSoundFile#m_nMusicSpeed.; |
| 676 | m_nPatternDelaycxx . . $ CSoundFile#m_nPatternDelay. = 0; |
| 677 | m_nFrameDelaycxx . . $ CSoundFile#m_nFrameDelay. = 0; |
| 678 | m_nBufferCountcxx . . $ CSoundFile#m_nBufferCount. = 0; |
| 679 | m_dwSongFlagscxx . . $ CSoundFile#m_dwSongFlags. |= SONG_PATTERNLOOPcxx . . $ `ext/psmplug/sndfile.h:242:9`!; |
| 680 | } |
| 681 | } |
| 682 | |
| 683 | |
| 684 | UINTcxx . . $ UINT# CSoundFilecxx . . $ CSoundFile#::GetSampleNamecxx . . $ CSoundFile#GetSampleName(bd66cc884609c19d).(UINTcxx . . $ UINT# nSample,LPSTRcxx . . $ LPSTR# s) const |
| 685 | //-------------------------------------------------------- |
| 686 | { |
| 687 | char sztmp[40] = ""; // changed from CHAR |
| 688 | if (nSample < MAX_SAMPLEScxx . . $ `ext/psmplug/sndfile.h:25:9`!) |
| 689 | memcpy(sztmp, m_szNamescxx . . $ CSoundFile#m_szNames.[nSample], 32); |
| 690 | sztmp[31] = 0; |
| 691 | if (s) strcpy(s, sztmp); |
| 692 | return strlen(sztmp); |
| 693 | } |
| 694 | |
| 695 | |
| 696 | UINTcxx . . $ UINT# CSoundFilecxx . . $ CSoundFile#::GetInstrumentNamecxx . . $ CSoundFile#GetInstrumentName(bd66cc884609c19d).(UINTcxx . . $ UINT# nInstr,LPSTRcxx . . $ LPSTR# s) const |
| 697 | //----------------------------------------------------------- |
| 698 | { |
| 699 | char sztmp[40] = ""; // changed from CHAR |
| 700 | if ((nInstr >= MAX_INSTRUMENTScxx . . $ `ext/psmplug/sndfile.h:26:9`!) || (!Headerscxx . . $ CSoundFile#Headers.[nInstr])) |
| 701 | { |
| 702 | if (s) *s = 0; |
| 703 | return 0; |
| 704 | } |
| 705 | INSTRUMENTHEADERcxx . . $ INSTRUMENTHEADER# *penv = Headerscxx . . $ CSoundFile#Headers.[nInstr]; |
| 706 | memcpy(sztmp, penv->namecxx . . $ _INSTRUMENTHEADER#name., 32); |
| 707 | sztmp[31] = 0; |
| 708 | if (s) strcpy(s, sztmp); |
| 709 | return strlen(sztmp); |
| 710 | } |
| 711 | |
| 712 | // Flags: |
| 713 | // 0 = signed 8-bit PCM data (default) |
| 714 | // 1 = unsigned 8-bit PCM data |
| 715 | // 2 = 8-bit ADPCM data with linear table |
| 716 | // 3 = 4-bit ADPCM data |
| 717 | // 4 = 16-bit ADPCM data with linear table |
| 718 | // 5 = signed 16-bit PCM data |
| 719 | // 6 = unsigned 16-bit PCM data |
| 720 | // |
| 721 | // Does unaligned WORD/DWORD stores to pIns->pSample with the |
| 722 | // assumption that malloc() returns aligned memory already. |
| 723 | // |
| 724 | UINTcxx . . $ UINT# CSoundFilecxx . . $ CSoundFile#::ReadSamplecxx . . $ CSoundFile#ReadSample(c75afd520c6e07d).(MODINSTRUMENTcxx . . $ MODINSTRUMENT# *pIns, UINTcxx . . $ UINT# nFlags, LPCSTRcxx . . $ LPCSTR# lpMemFile, DWORDcxx . . $ DWORD# dwMemLength) |
| 725 | //------------------------------------------------------------------------------ |
| 726 | { |
| 727 | UINTcxx . . $ UINT# len = 0, mem; |
| 728 | |
| 729 | // Disable >2Gb samples,(preventing buffer overflow in AllocateSample) |
| 730 | if ((!pIns) || ((int)pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength. < 4) || (!lpMemFile)) return 0; |
| 731 | if (pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength. > MAX_SAMPLE_LENGTHcxx . . $ `ext/psmplug/sndfile.h:21:9`!) pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength. = MAX_SAMPLE_LENGTHcxx . . $ `ext/psmplug/sndfile.h:21:9`!; |
| 732 | mem = pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength.+6; |
| 733 | pIns->uFlagscxx . . $ _MODINSTRUMENT#uFlags. &= ~(CHN_16BITcxx . . $ `ext/psmplug/sndfile.h:73:9`!|CHN_STEREOcxx . . $ `ext/psmplug/sndfile.h:79:9`!); |
| 734 | if (nFlags & RSF_16BITcxx . . $ `ext/psmplug/sndfile.h:168:9`!) |
| 735 | { |
| 736 | mem *= 2; |
| 737 | pIns->uFlagscxx . . $ _MODINSTRUMENT#uFlags. |= CHN_16BITcxx . . $ `ext/psmplug/sndfile.h:73:9`!; |
| 738 | } |
| 739 | if (nFlags & RSF_STEREOcxx . . $ `ext/psmplug/sndfile.h:169:9`!) |
| 740 | { |
| 741 | mem *= 2; |
| 742 | pIns->uFlagscxx . . $ _MODINSTRUMENT#uFlags. |= CHN_STEREOcxx . . $ `ext/psmplug/sndfile.h:79:9`!; |
| 743 | } |
| 744 | if ((pIns->pSamplecxx . . $ _MODINSTRUMENT#pSample. = AllocateSamplecxx . . $ CSoundFile#AllocateSample(f3169d5868adb627).(mem)) == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 745 | { |
| 746 | pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength. = 0; |
| 747 | return 0; |
| 748 | } |
| 749 | switch(nFlags) |
| 750 | { |
| 751 | // 1: 8-bit unsigned PCM data |
| 752 | case RS_PCM8Ucxx . . $ `ext/psmplug/sndfile.h:172:9`!: |
| 753 | { |
| 754 | len = pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength.; |
| 755 | if (len > dwMemLength) len = pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength. = dwMemLength; |
| 756 | signed char *pSample = pIns->pSamplecxx . . $ _MODINSTRUMENT#pSample.; |
| 757 | for (UINTcxx . . $ UINT# j=0; j<len; j++) pSample[j] = (signed char)(lpMemFile[j] - 0x80); |
| 758 | } |
| 759 | break; |
| 760 | |
| 761 | // 2: 8-bit ADPCM data with linear table |
| 762 | case RS_PCM8Dcxx . . $ `ext/psmplug/sndfile.h:173:9`!: |
| 763 | { |
| 764 | len = pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength.; |
| 765 | if (len > dwMemLength) break; |
| 766 | signed char *pSample = pIns->pSamplecxx . . $ _MODINSTRUMENT#pSample.; |
| 767 | const signed char *p = (const signed char *)lpMemFile; |
| 768 | int delta = 0; |
| 769 | |
| 770 | for (UINTcxx . . $ UINT# j=0; j<len; j++) |
| 771 | { |
| 772 | delta += p[j]; |
| 773 | *pSample++ = (signed char)delta; |
| 774 | } |
| 775 | } |
| 776 | break; |
| 777 | |
| 778 | // 3: 4-bit ADPCM data |
| 779 | case RS_ADPCM4cxx . . $ `ext/psmplug/sndfile.h:174:9`!: |
| 780 | { |
| 781 | len = (pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength. + 1) / 2; |
| 782 | if (len > dwMemLength - 16 || dwMemLength < 16) break; |
| 783 | memcpy(CompressionTablecxx . . $ CSoundFile#CompressionTable., lpMemFile, 16); |
| 784 | lpMemFile += 16; |
| 785 | signed char *pSample = pIns->pSamplecxx . . $ _MODINSTRUMENT#pSample.; |
| 786 | signed char delta = 0; |
| 787 | for (UINTcxx . . $ UINT# j=0; j<len; j++) |
| 788 | { |
| 789 | BYTEcxx . . $ BYTE# b0 = (BYTEcxx . . $ BYTE#)lpMemFile[j]; |
| 790 | BYTEcxx . . $ BYTE# b1 = (BYTEcxx . . $ BYTE#)(lpMemFile[j] >> 4); |
| 791 | delta = (signed char)GetDeltaValuecxx . . $ CSoundFile#GetDeltaValue(354b5d0578f462b3).((int)delta, b0); |
| 792 | pSample[0] = delta; |
| 793 | delta = (signed char)GetDeltaValuecxx . . $ CSoundFile#GetDeltaValue(354b5d0578f462b3).((int)delta, b1); |
| 794 | pSample[1] = delta; |
| 795 | pSample += 2; |
| 796 | } |
| 797 | len += 16; |
| 798 | } |
| 799 | break; |
| 800 | |
| 801 | // 4: 16-bit ADPCM data with linear table |
| 802 | case RS_PCM16Dcxx . . $ `ext/psmplug/sndfile.h:175:9`!: |
| 803 | { |
| 804 | len = pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength. * 2; |
| 805 | if (len > dwMemLength) break; |
| 806 | int16_t *pSample = (int16_t *)pIns->pSamplecxx . . $ _MODINSTRUMENT#pSample.; |
| 807 | LPCBYTEcxx . . $ LPCBYTE# p = (LPCBYTEcxx . . $ LPCBYTE#)lpMemFile; |
| 808 | int delta16 = 0; |
| 809 | for (UINTcxx . . $ UINT# j=0; j<len; j+=2, p += 2) |
| 810 | { |
| 811 | delta16 += (int16_t)READ_LE16cxx . . $ READ_LE16(469dcb4e54b221a8).(p); |
| 812 | *pSample++ = (int16_t )delta16; |
| 813 | } |
| 814 | } |
| 815 | break; |
| 816 | |
| 817 | // 5: 16-bit signed PCM data |
| 818 | case RS_PCM16Scxx . . $ `ext/psmplug/sndfile.h:176:9`!: |
| 819 | { |
| 820 | len = pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength. * 2; |
| 821 | if (len <= dwMemLength) memcpy(pIns->pSamplecxx . . $ _MODINSTRUMENT#pSample., lpMemFile, len); |
| 822 | int16_t *pSample = (int16_t *)pIns->pSamplecxx . . $ _MODINSTRUMENT#pSample.; |
| 823 | for (UINTcxx . . $ UINT# j=0; j<len; j+=2) |
| 824 | { |
| 825 | int16_t rawSample = *pSample; |
| 826 | *pSample++ = bswapLE16cxx . . $ `ext/psmplug/sndfile.h:989:9`!(rawSample); |
| 827 | } |
| 828 | } |
| 829 | break; |
| 830 | |
| 831 | // 16-bit signed mono PCM motorola byte order |
| 832 | case RS_PCM16Mcxx . . $ `ext/psmplug/sndfile.h:178:9`!: |
| 833 | len = pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength. * 2; |
| 834 | if (len > dwMemLength) len = dwMemLength & ~1; |
| 835 | if (len > 1) |
| 836 | { |
| 837 | char *pSample = (char *)pIns->pSamplecxx . . $ _MODINSTRUMENT#pSample.; |
| 838 | LPCBYTEcxx . . $ LPCBYTE# pSrc = (LPCBYTEcxx . . $ LPCBYTE#)lpMemFile; |
| 839 | for (UINTcxx . . $ UINT# j=0; j<len; j+=2) { |
| 840 | *((uint16_tcxx . . $ uint16_t# *)(pSample+j)) = READ_BE16cxx . . $ READ_BE16(469dcb4e54b221a8).(pSrc+j); |
| 841 | } |
| 842 | } |
| 843 | break; |
| 844 | |
| 845 | // 6: 16-bit unsigned PCM data |
| 846 | case RS_PCM16Ucxx . . $ `ext/psmplug/sndfile.h:177:9`!: |
| 847 | { |
| 848 | len = pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength. * 2; |
| 849 | if (len > dwMemLength) break; |
| 850 | int16_t *pSample = (int16_t *)pIns->pSamplecxx . . $ _MODINSTRUMENT#pSample.; |
| 851 | LPCBYTEcxx . . $ LPCBYTE# pSrc = (LPCBYTEcxx . . $ LPCBYTE#)lpMemFile; |
| 852 | for (UINTcxx . . $ UINT# j=0; j<len; j+=2, pSrc += 2) { |
| 853 | *pSample++ = (int16_t)(READ_LE16cxx . . $ READ_LE16(469dcb4e54b221a8).(pSrc) - 0x8000); |
| 854 | } |
| 855 | } |
| 856 | break; |
| 857 | |
| 858 | // 16-bit signed stereo big endian |
| 859 | case RS_STPCM16Mcxx . . $ `ext/psmplug/sndfile.h:185:9`!: |
| 860 | len = pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength. * 2; |
| 861 | if (len*2 <= dwMemLength) |
| 862 | { |
| 863 | char *pSample = (char *)pIns->pSamplecxx . . $ _MODINSTRUMENT#pSample.; |
| 864 | LPCBYTEcxx . . $ LPCBYTE# pSrc = (LPCBYTEcxx . . $ LPCBYTE#)lpMemFile; |
| 865 | for (UINTcxx . . $ UINT# j=0; j<len; j+=2) { |
| 866 | *((uint16_tcxx . . $ uint16_t# *)(pSample+j*2)) = READ_BE16cxx . . $ READ_BE16(469dcb4e54b221a8).(pSrc+j); |
| 867 | *((uint16_tcxx . . $ uint16_t# *)(pSample+j*2+2)) = READ_BE16cxx . . $ READ_BE16(469dcb4e54b221a8).(pSrc+j+len); |
| 868 | } |
| 869 | len *= 2; |
| 870 | } |
| 871 | break; |
| 872 | |
| 873 | // 8-bit stereo samples |
| 874 | case RS_STPCM8Scxx . . $ `ext/psmplug/sndfile.h:179:9`!: |
| 875 | case RS_STPCM8Ucxx . . $ `ext/psmplug/sndfile.h:180:9`!: |
| 876 | case RS_STPCM8Dcxx . . $ `ext/psmplug/sndfile.h:181:9`!: |
| 877 | { |
| 878 | int iadd_l = 0, iadd_r = 0; |
| 879 | if (nFlags == RS_STPCM8Ucxx . . $ `ext/psmplug/sndfile.h:180:9`!) { iadd_l = iadd_r = -128; } |
| 880 | len = pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength.; |
| 881 | signed char *psrc = (signed char *)lpMemFile; |
| 882 | signed char *pSample = (signed char *)pIns->pSamplecxx . . $ _MODINSTRUMENT#pSample.; |
| 883 | if (len*2 > dwMemLength) break; |
| 884 | for (UINTcxx . . $ UINT# j=0; j<len; j++) |
| 885 | { |
| 886 | pSample[j*2] = (signed char)(psrc[0] + iadd_l); |
| 887 | pSample[j*2+1] = (signed char)(psrc[len] + iadd_r); |
| 888 | psrc++; |
| 889 | if (nFlags == RS_STPCM8Dcxx . . $ `ext/psmplug/sndfile.h:181:9`!) |
| 890 | { |
| 891 | iadd_l = pSample[j*2]; |
| 892 | iadd_r = pSample[j*2+1]; |
| 893 | } |
| 894 | } |
| 895 | len *= 2; |
| 896 | } |
| 897 | break; |
| 898 | |
| 899 | // 16-bit stereo samples |
| 900 | case RS_STPCM16Scxx . . $ `ext/psmplug/sndfile.h:182:9`!: |
| 901 | case RS_STPCM16Ucxx . . $ `ext/psmplug/sndfile.h:183:9`!: |
| 902 | case RS_STPCM16Dcxx . . $ `ext/psmplug/sndfile.h:184:9`!: |
| 903 | { |
| 904 | int iadd_l = 0, iadd_r = 0; |
| 905 | if (nFlags == RS_STPCM16Ucxx . . $ `ext/psmplug/sndfile.h:183:9`!) { iadd_l = iadd_r = -0x8000; } |
| 906 | len = pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength.; |
| 907 | LPCBYTEcxx . . $ LPCBYTE# psrc0 = (LPCBYTEcxx . . $ LPCBYTE#)lpMemFile; |
| 908 | LPCBYTEcxx . . $ LPCBYTE# psrc1 = (LPCBYTEcxx . . $ LPCBYTE#)lpMemFile + len*2; |
| 909 | int16_t *pSample = (int16_t *)pIns->pSamplecxx . . $ _MODINSTRUMENT#pSample.; |
| 910 | if (len*4 > dwMemLength) break; |
| 911 | for (UINTcxx . . $ UINT# j=0; j<len; j++) |
| 912 | { |
| 913 | pSample[j*2] = (int16_t) (READ_LE16cxx . . $ READ_LE16(469dcb4e54b221a8).(psrc0) + iadd_l); |
| 914 | pSample[j*2+1] = (int16_t) (READ_LE16cxx . . $ READ_LE16(469dcb4e54b221a8).(psrc1) + iadd_r); |
| 915 | psrc0 += 2; |
| 916 | psrc1 += 2; |
| 917 | if (nFlags == RS_STPCM16Dcxx . . $ `ext/psmplug/sndfile.h:184:9`!) |
| 918 | { |
| 919 | iadd_l = pSample[j*2]; |
| 920 | iadd_r = pSample[j*2+1]; |
| 921 | } |
| 922 | } |
| 923 | len *= 4; |
| 924 | } |
| 925 | break; |
| 926 | |
| 927 | #ifndef MODPLUG_BASIC_SUPPORT |
| 928 | // 8-bit interleaved stereo samples |
| 929 | case RS_STIPCM8Scxx . . $ `ext/psmplug/sndfile.h:202:9`!: |
| 930 | case RS_STIPCM8Ucxx . . $ `ext/psmplug/sndfile.h:203:9`!: |
| 931 | { |
| 932 | int iadd = 0; |
| 933 | if (nFlags == RS_STIPCM8Ucxx . . $ `ext/psmplug/sndfile.h:203:9`!) { iadd = -0x80; } |
| 934 | len = pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength.; |
| 935 | if (len*2 > dwMemLength) len = dwMemLength >> 1; |
| 936 | LPBYTEcxx . . $ LPBYTE# psrc = (LPBYTEcxx . . $ LPBYTE#)lpMemFile; |
| 937 | LPBYTEcxx . . $ LPBYTE# pSample = (LPBYTEcxx . . $ LPBYTE#)pIns->pSamplecxx . . $ _MODINSTRUMENT#pSample.; |
| 938 | for (UINTcxx . . $ UINT# j=0; j<len; j++) |
| 939 | { |
| 940 | pSample[j*2] = (signed char)(psrc[0] + iadd); |
| 941 | pSample[j*2+1] = (signed char)(psrc[1] + iadd); |
| 942 | psrc+=2; |
| 943 | } |
| 944 | len *= 2; |
| 945 | } |
| 946 | break; |
| 947 | |
| 948 | // 16-bit interleaved stereo samples |
| 949 | case RS_STIPCM16Scxx . . $ `ext/psmplug/sndfile.h:204:9`!: |
| 950 | case RS_STIPCM16Ucxx . . $ `ext/psmplug/sndfile.h:205:9`!: |
| 951 | { |
| 952 | int iadd = 0; |
| 953 | if (nFlags == RS_STIPCM16Ucxx . . $ `ext/psmplug/sndfile.h:205:9`!) iadd = -32768; |
| 954 | len = pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength.; |
| 955 | if (len*4 > dwMemLength) len = dwMemLength >> 2; |
| 956 | LPCBYTEcxx . . $ LPCBYTE# psrc = (LPCBYTEcxx . . $ LPCBYTE#)lpMemFile; |
| 957 | int16_t *pSample = (int16_t *)pIns->pSamplecxx . . $ _MODINSTRUMENT#pSample.; |
| 958 | for (UINTcxx . . $ UINT# j=0; j<len; j++) |
| 959 | { |
| 960 | pSample[j*2] = (int16_t)(READ_LE16cxx . . $ READ_LE16(469dcb4e54b221a8).(psrc+0) + iadd); |
| 961 | pSample[j*2+1] = (int16_t)(READ_LE16cxx . . $ READ_LE16(469dcb4e54b221a8).(psrc+2) + iadd); |
| 962 | psrc += 4; |
| 963 | } |
| 964 | len *= 4; |
| 965 | } |
| 966 | break; |
| 967 | |
| 968 | // PTM 8bit delta to 16-bit sample |
| 969 | case RS_PTM8DTO16cxx . . $ `ext/psmplug/sndfile.h:200:9`!: |
| 970 | { |
| 971 | len = pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength. * 2; |
| 972 | if (len > dwMemLength) break; |
| 973 | int8_t *pSample = (int8_t *)pIns->pSamplecxx . . $ _MODINSTRUMENT#pSample.; |
| 974 | int8_t delta8 = 0; |
| 975 | for (UINTcxx . . $ UINT# j=0; j<len; j++) |
| 976 | { |
| 977 | delta8 += lpMemFile[j]; |
| 978 | *pSample++ = delta8; |
| 979 | } |
| 980 | uint16_tcxx . . $ uint16_t# *pSampleW = (uint16_tcxx . . $ uint16_t# *)pIns->pSamplecxx . . $ _MODINSTRUMENT#pSample.; |
| 981 | for (UINTcxx . . $ UINT# j=0; j<len; j+=2) // swaparoni! |
| 982 | { |
| 983 | uint16_tcxx . . $ uint16_t# rawSample = *pSampleW; |
| 984 | *pSampleW++ = bswapLE16cxx . . $ `ext/psmplug/sndfile.h:989:9`!(rawSample); |
| 985 | } |
| 986 | } |
| 987 | break; |
| 988 | #endif // !MODPLUG_BASIC_SUPPORT |
| 989 | |
| 990 | // Default: 8-bit signed PCM data |
| 991 | default: |
| 992 | len = pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength.; |
| 993 | if (len > dwMemLength) len = pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength. = dwMemLength; |
| 994 | memcpy(pIns->pSamplecxx . . $ _MODINSTRUMENT#pSample., lpMemFile, len); |
| 995 | } |
| 996 | if (len > dwMemLength) |
| 997 | { |
| 998 | if (pIns->pSamplecxx . . $ _MODINSTRUMENT#pSample.) |
| 999 | { |
| 1000 | pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength. = 0; |
| 1001 | FreeSamplecxx . . $ CSoundFile#FreeSample(5d22bdacc48458e8).(pIns->pSamplecxx . . $ _MODINSTRUMENT#pSample.); |
| 1002 | pIns->pSamplecxx . . $ _MODINSTRUMENT#pSample. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 1003 | } |
| 1004 | return 0; |
| 1005 | } |
| 1006 | AdjustSampleLoopcxx . . $ CSoundFile#AdjustSampleLoop(4571e2351ba6f5eb).(pIns); |
| 1007 | return len; |
| 1008 | } |
| 1009 | |
| 1010 | |
| 1011 | void CSoundFilecxx . . $ CSoundFile#::AdjustSampleLoopcxx . . $ CSoundFile#AdjustSampleLoop(4571e2351ba6f5eb).(MODINSTRUMENTcxx . . $ MODINSTRUMENT# *pIns) |
| 1012 | //---------------------------------------------------- |
| 1013 | { |
| 1014 | if (!pIns->pSamplecxx . . $ _MODINSTRUMENT#pSample.) return; |
| 1015 | if (pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength. > MAX_SAMPLE_LENGTHcxx . . $ `ext/psmplug/sndfile.h:21:9`!) pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength. = MAX_SAMPLE_LENGTHcxx . . $ `ext/psmplug/sndfile.h:21:9`!; |
| 1016 | if (pIns->nLoopEndcxx . . $ _MODINSTRUMENT#nLoopEnd. > pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength.) pIns->nLoopEndcxx . . $ _MODINSTRUMENT#nLoopEnd. = pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength.; |
| 1017 | if (pIns->nLoopStartcxx . . $ _MODINSTRUMENT#nLoopStart. > pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength.+2) pIns->nLoopStartcxx . . $ _MODINSTRUMENT#nLoopStart. = pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength.+2; |
| 1018 | if (pIns->nLoopStartcxx . . $ _MODINSTRUMENT#nLoopStart.+2 >= pIns->nLoopEndcxx . . $ _MODINSTRUMENT#nLoopEnd.) |
| 1019 | { |
| 1020 | pIns->nLoopStartcxx . . $ _MODINSTRUMENT#nLoopStart. = pIns->nLoopEndcxx . . $ _MODINSTRUMENT#nLoopEnd. = 0; |
| 1021 | pIns->uFlagscxx . . $ _MODINSTRUMENT#uFlags. &= ~CHN_LOOPcxx . . $ `ext/psmplug/sndfile.h:74:9`!; |
| 1022 | } |
| 1023 | UINTcxx . . $ UINT# len = pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength.; |
| 1024 | if (pIns->uFlagscxx . . $ _MODINSTRUMENT#uFlags. & CHN_16BITcxx . . $ `ext/psmplug/sndfile.h:73:9`!) |
| 1025 | { |
| 1026 | int16_t *pSample = (int16_t *)pIns->pSamplecxx . . $ _MODINSTRUMENT#pSample.; |
| 1027 | // Adjust end of sample |
| 1028 | if (pIns->uFlagscxx . . $ _MODINSTRUMENT#uFlags. & CHN_STEREOcxx . . $ `ext/psmplug/sndfile.h:79:9`!) |
| 1029 | { |
| 1030 | pSample[len*2+6] = pSample[len*2+4] = pSample[len*2+2] = pSample[len*2] = 0; |
| 1031 | pSample[len*2+7] = pSample[len*2+5] = pSample[len*2+3] = pSample[len*2+1] = 0; |
| 1032 | } else |
| 1033 | { |
| 1034 | pSample[len+4] = pSample[len+3] = pSample[len+2] = pSample[len+1] = pSample[len] = 0; |
| 1035 | } |
| 1036 | if ((pIns->uFlagscxx . . $ _MODINSTRUMENT#uFlags. & (CHN_LOOPcxx . . $ `ext/psmplug/sndfile.h:74:9`!|CHN_PINGPONGLOOPcxx . . $ `ext/psmplug/sndfile.h:75:9`!|CHN_STEREOcxx . . $ `ext/psmplug/sndfile.h:79:9`!)) == CHN_LOOPcxx . . $ `ext/psmplug/sndfile.h:74:9`!) |
| 1037 | { |
| 1038 | // Fix bad loops |
| 1039 | if ((pIns->nLoopEndcxx . . $ _MODINSTRUMENT#nLoopEnd.+3 >= pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength.) || (m_nTypecxx . . $ CSoundFile#m_nType. & MOD_TYPE_S3Mcxx . . $ `ext/psmplug/sndfile.h:41:9`!)) |
| 1040 | { |
| 1041 | pSample[pIns->nLoopEndcxx . . $ _MODINSTRUMENT#nLoopEnd.] = pSample[pIns->nLoopStartcxx . . $ _MODINSTRUMENT#nLoopStart.]; |
| 1042 | pSample[pIns->nLoopEndcxx . . $ _MODINSTRUMENT#nLoopEnd.+1] = pSample[pIns->nLoopStartcxx . . $ _MODINSTRUMENT#nLoopStart.+1]; |
| 1043 | pSample[pIns->nLoopEndcxx . . $ _MODINSTRUMENT#nLoopEnd.+2] = pSample[pIns->nLoopStartcxx . . $ _MODINSTRUMENT#nLoopStart.+2]; |
| 1044 | pSample[pIns->nLoopEndcxx . . $ _MODINSTRUMENT#nLoopEnd.+3] = pSample[pIns->nLoopStartcxx . . $ _MODINSTRUMENT#nLoopStart.+3]; |
| 1045 | pSample[pIns->nLoopEndcxx . . $ _MODINSTRUMENT#nLoopEnd.+4] = pSample[pIns->nLoopStartcxx . . $ _MODINSTRUMENT#nLoopStart.+4]; |
| 1046 | } |
| 1047 | } |
| 1048 | } else |
| 1049 | { |
| 1050 | signed char *pSample = pIns->pSamplecxx . . $ _MODINSTRUMENT#pSample.; |
| 1051 | // Crappy samples (except chiptunes) ? |
| 1052 | if ((pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength. > 0x100) && (m_nTypecxx . . $ CSoundFile#m_nType. & (MOD_TYPE_MODcxx . . $ `ext/psmplug/sndfile.h:40:9`!|MOD_TYPE_S3Mcxx . . $ `ext/psmplug/sndfile.h:41:9`!)) |
| 1053 | && (!(pIns->uFlagscxx . . $ _MODINSTRUMENT#uFlags. & CHN_STEREOcxx . . $ `ext/psmplug/sndfile.h:79:9`!))) |
| 1054 | { |
| 1055 | int smpend = pSample[pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength.-1], smpfix = 0, kscan; |
| 1056 | for (kscan=pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength.-1; kscan>0; kscan--) |
| 1057 | { |
| 1058 | smpfix = pSample[kscan-1]; |
| 1059 | if (smpfix != smpend) break; |
| 1060 | } |
| 1061 | int delta = smpfix - smpend; |
| 1062 | if (((!(pIns->uFlagscxx . . $ _MODINSTRUMENT#uFlags. & CHN_LOOPcxx . . $ `ext/psmplug/sndfile.h:74:9`!)) || (kscan > (int)pIns->nLoopEndcxx . . $ _MODINSTRUMENT#nLoopEnd.)) |
| 1063 | && ((delta < -8) || (delta > 8))) |
| 1064 | { |
| 1065 | while (kscan<(int)pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength.) |
| 1066 | { |
| 1067 | if (!(kscan & 7)) |
| 1068 | { |
| 1069 | if (smpfix > 0) smpfix--; |
| 1070 | if (smpfix < 0) smpfix++; |
| 1071 | } |
| 1072 | pSample[kscan] = (signed char)smpfix; |
| 1073 | kscan++; |
| 1074 | } |
| 1075 | } |
| 1076 | } |
| 1077 | // Adjust end of sample |
| 1078 | if (pIns->uFlagscxx . . $ _MODINSTRUMENT#uFlags. & CHN_STEREOcxx . . $ `ext/psmplug/sndfile.h:79:9`!) |
| 1079 | { |
| 1080 | pSample[len*2+6] = pSample[len*2+4] = pSample[len*2+2] = pSample[len*2] = 0; |
| 1081 | pSample[len*2+7] = pSample[len*2+5] = pSample[len*2+3] = pSample[len*2+1] = 0; |
| 1082 | |
| 1083 | } else |
| 1084 | { |
| 1085 | pSample[len+4] = pSample[len+3] = pSample[len+2] = pSample[len+1] = pSample[len] = 0; |
| 1086 | } |
| 1087 | if ((pIns->uFlagscxx . . $ _MODINSTRUMENT#uFlags. & (CHN_LOOPcxx . . $ `ext/psmplug/sndfile.h:74:9`!|CHN_PINGPONGLOOPcxx . . $ `ext/psmplug/sndfile.h:75:9`!|CHN_STEREOcxx . . $ `ext/psmplug/sndfile.h:79:9`!)) == CHN_LOOPcxx . . $ `ext/psmplug/sndfile.h:74:9`!) |
| 1088 | { |
| 1089 | if ((pIns->nLoopEndcxx . . $ _MODINSTRUMENT#nLoopEnd.+3 >= pIns->nLengthcxx . . $ _MODINSTRUMENT#nLength.) || (m_nTypecxx . . $ CSoundFile#m_nType. & (MOD_TYPE_MODcxx . . $ `ext/psmplug/sndfile.h:40:9`!|MOD_TYPE_S3Mcxx . . $ `ext/psmplug/sndfile.h:41:9`!))) |
| 1090 | { |
| 1091 | pSample[pIns->nLoopEndcxx . . $ _MODINSTRUMENT#nLoopEnd.] = pSample[pIns->nLoopStartcxx . . $ _MODINSTRUMENT#nLoopStart.]; |
| 1092 | pSample[pIns->nLoopEndcxx . . $ _MODINSTRUMENT#nLoopEnd.+1] = pSample[pIns->nLoopStartcxx . . $ _MODINSTRUMENT#nLoopStart.+1]; |
| 1093 | pSample[pIns->nLoopEndcxx . . $ _MODINSTRUMENT#nLoopEnd.+2] = pSample[pIns->nLoopStartcxx . . $ _MODINSTRUMENT#nLoopStart.+2]; |
| 1094 | pSample[pIns->nLoopEndcxx . . $ _MODINSTRUMENT#nLoopEnd.+3] = pSample[pIns->nLoopStartcxx . . $ _MODINSTRUMENT#nLoopStart.+3]; |
| 1095 | pSample[pIns->nLoopEndcxx . . $ _MODINSTRUMENT#nLoopEnd.+4] = pSample[pIns->nLoopStartcxx . . $ _MODINSTRUMENT#nLoopStart.+4]; |
| 1096 | } |
| 1097 | } |
| 1098 | } |
| 1099 | } |
| 1100 | |
| 1101 | |
| 1102 | ///////////////////////////////////////////////////////////// |
| 1103 | // Transpose <-> Frequency conversions |
| 1104 | |
| 1105 | // returns 8363*2^((transp*128+ftune)/(12*128)) |
| 1106 | DWORDcxx . . $ DWORD# CSoundFilecxx . . $ CSoundFile#::TransposeToFrequencycxx . . $ CSoundFile#TransposeToFrequency(58c590d1186ea715).(int transp, int ftune) |
| 1107 | //----------------------------------------------------------- |
| 1108 | { |
| 1109 | return (DWORDcxx . . $ DWORD#)(8363*powcxx . . $ pow(1b569819b62499ac).(2, (double)(transp*128+ftune)/(1536))); |
| 1110 | } |
| 1111 | |
| 1112 | |
| 1113 | // returns 12*128*log2(freq/8363) |
| 1114 | int CSoundFilecxx . . $ CSoundFile#::FrequencyToTransposecxx . . $ CSoundFile#FrequencyToTranspose(4c679297bf94b9eb).(DWORDcxx . . $ DWORD# freq) |
| 1115 | //---------------------------------------------- |
| 1116 | { |
| 1117 | return int(1536*(logcxx . . $ log(447c67c6676f75c3).(freq/8363.0)/logcxx . . $ log(447c67c6676f75c3).(2.0))); |
| 1118 | } |
| 1119 | |
| 1120 | |
| 1121 | void CSoundFilecxx . . $ CSoundFile#::FrequencyToTransposecxx . . $ CSoundFile#FrequencyToTranspose(4571e2351ba6f5eb).(MODINSTRUMENTcxx . . $ MODINSTRUMENT# *psmp) |
| 1122 | //-------------------------------------------------------- |
| 1123 | { |
| 1124 | int f2t = FrequencyToTransposecxx . . $ CSoundFile#FrequencyToTranspose(4c679297bf94b9eb).(psmp->nC4Speedcxx . . $ _MODINSTRUMENT#nC4Speed.); |
| 1125 | int transp = f2t >> 7; |
| 1126 | int ftune = f2t & 0x7F; |
| 1127 | if (ftune > 80) |
| 1128 | { |
| 1129 | transp++; |
| 1130 | ftune -= 128; |
| 1131 | } |
| 1132 | if (transp > 127) transp = 127; |
| 1133 | if (transp < -127) transp = -127; |
| 1134 | psmp->RelativeTonecxx . . $ _MODINSTRUMENT#RelativeTone. = transp; |
| 1135 | psmp->nFineTunecxx . . $ _MODINSTRUMENT#nFineTune. = ftune; |
| 1136 | } |
| 1137 | |
| 1138 | |
| 1139 | void CSoundFilecxx . . $ CSoundFile#::CheckCPUUsagecxx . . $ CSoundFile#CheckCPUUsage(cb2f890c2fdad230).(UINTcxx . . $ UINT# nCPU) |
| 1140 | //--------------------------------------- |
| 1141 | { |
| 1142 | if (nCPU > 100) nCPU = 100; |
| 1143 | gnCPUUsagecxx . . $ CSoundFile#gnCPUUsage. = nCPU; |
| 1144 | if (nCPU < 90) |
| 1145 | { |
| 1146 | m_dwSongFlagscxx . . $ CSoundFile#m_dwSongFlags. &= ~SONG_CPUVERYHIGHcxx . . $ `ext/psmplug/sndfile.h:248:9`!; |
| 1147 | } else |
| 1148 | if ((m_dwSongFlagscxx . . $ CSoundFile#m_dwSongFlags. & SONG_CPUVERYHIGHcxx . . $ `ext/psmplug/sndfile.h:248:9`!) && (nCPU >= 94)) |
| 1149 | { |
| 1150 | UINTcxx . . $ UINT# i=MAX_CHANNELScxx . . $ `ext/psmplug/sndfile.h:27:9`!; |
| 1151 | while (i >= 8) |
| 1152 | { |
| 1153 | i--; |
| 1154 | if (Chncxx . . $ CSoundFile#Chn.[i].nLengthcxx . . $ _MODCHANNEL#nLength.) |
| 1155 | { |
| 1156 | Chncxx . . $ CSoundFile#Chn.[i].nLengthcxx . . $ _MODCHANNEL#nLength. = Chncxx . . $ CSoundFile#Chn.[i].nPoscxx . . $ _MODCHANNEL#nPos. = 0; |
| 1157 | nCPU -= 2; |
| 1158 | if (nCPU < 94) break; |
| 1159 | } |
| 1160 | } |
| 1161 | } else |
| 1162 | if (nCPU > 90) |
| 1163 | { |
| 1164 | m_dwSongFlagscxx . . $ CSoundFile#m_dwSongFlags. |= SONG_CPUVERYHIGHcxx . . $ `ext/psmplug/sndfile.h:248:9`!; |
| 1165 | } |
| 1166 | } |
| 1167 | |
| 1168 | |
| 1169 | BOOLcxx . . $ BOOL# CSoundFilecxx . . $ CSoundFile#::SetPatternNamecxx . . $ CSoundFile#SetPatternName(33974edd1b6ef6cc).(UINTcxx . . $ UINT# nPat, LPCSTRcxx . . $ LPCSTR# lpszName) |
| 1170 | //--------------------------------------------------------- |
| 1171 | { |
| 1172 | char szName[MAX_PATTERNNAMEcxx . . $ `ext/psmplug/sndfile.h:32:9`!] = ""; |
| 1173 | // check input arguments |
| 1174 | if (nPat >= MAX_PATTERNScxx . . $ `ext/psmplug/sndfile.h:24:9`!) return FALSEcxx . . $ `ext/psmplug/stdafx.h:93:9`!; |
| 1175 | if (lpszName == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) return(FALSEcxx . . $ `ext/psmplug/stdafx.h:93:9`!); |
| 1176 | |
| 1177 | if (lpszName) lstrcpynAcxx . . $ `ext/psmplug/stdafx.h:76:9`!(szName, lpszName, MAX_PATTERNNAMEcxx . . $ `ext/psmplug/sndfile.h:32:9`!-1); |
| 1178 | szName[MAX_PATTERNNAMEcxx . . $ `ext/psmplug/sndfile.h:32:9`!-1] = 0; |
| 1179 | if (!m_lpszPatternNamescxx . . $ CSoundFile#m_lpszPatternNames.) m_nPatternNamescxx . . $ CSoundFile#m_nPatternNames. = 0; |
| 1180 | if (nPat >= m_nPatternNamescxx . . $ CSoundFile#m_nPatternNames.) |
| 1181 | { |
| 1182 | if (!lpszName[0]) return TRUEcxx . . $ `ext/psmplug/stdafx.h:97:9`!; |
| 1183 | UINTcxx . . $ UINT# len = (nPat+1)*MAX_PATTERNNAMEcxx . . $ `ext/psmplug/sndfile.h:32:9`!; |
| 1184 | char *p = new char[len]; |
| 1185 | if (!p) return FALSEcxx . . $ `ext/psmplug/stdafx.h:93:9`!; |
| 1186 | memset(p, 0, len); |
| 1187 | if (m_lpszPatternNamescxx . . $ CSoundFile#m_lpszPatternNames.) |
| 1188 | { |
| 1189 | memcpy(p, m_lpszPatternNamescxx . . $ CSoundFile#m_lpszPatternNames., m_nPatternNamescxx . . $ CSoundFile#m_nPatternNames. * MAX_PATTERNNAMEcxx . . $ `ext/psmplug/sndfile.h:32:9`!); |
| 1190 | delete [] m_lpszPatternNamescxx . . $ CSoundFile#m_lpszPatternNames.; |
| 1191 | m_lpszPatternNamescxx . . $ CSoundFile#m_lpszPatternNames. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 1192 | } |
| 1193 | m_lpszPatternNamescxx . . $ CSoundFile#m_lpszPatternNames. = p; |
| 1194 | m_nPatternNamescxx . . $ CSoundFile#m_nPatternNames. = nPat + 1; |
| 1195 | } |
| 1196 | memcpy(m_lpszPatternNamescxx . . $ CSoundFile#m_lpszPatternNames. + nPat * MAX_PATTERNNAMEcxx . . $ `ext/psmplug/sndfile.h:32:9`!, szName, MAX_PATTERNNAMEcxx . . $ `ext/psmplug/sndfile.h:32:9`!); |
| 1197 | return TRUEcxx . . $ `ext/psmplug/stdafx.h:97:9`!; |
| 1198 | } |
| 1199 | |
| 1200 | |
| 1201 | BOOLcxx . . $ BOOL# CSoundFilecxx . . $ CSoundFile#::GetPatternNamecxx . . $ CSoundFile#GetPatternName(a182617911d80fb2).(UINTcxx . . $ UINT# nPat, LPSTRcxx . . $ LPSTR# lpszName, UINTcxx . . $ UINT# cbSize) const |
| 1202 | //--------------------------------------------------------------------------- |
| 1203 | { |
| 1204 | if ((!lpszName) || (!cbSize)) return FALSEcxx . . $ `ext/psmplug/stdafx.h:93:9`!; |
| 1205 | lpszName[0] = 0; |
| 1206 | if (cbSize > MAX_PATTERNNAMEcxx . . $ `ext/psmplug/sndfile.h:32:9`!) cbSize = MAX_PATTERNNAMEcxx . . $ `ext/psmplug/sndfile.h:32:9`!; |
| 1207 | if ((m_lpszPatternNamescxx . . $ CSoundFile#m_lpszPatternNames.) && (nPat < m_nPatternNamescxx . . $ CSoundFile#m_nPatternNames.)) |
| 1208 | { |
| 1209 | memcpy(lpszName, m_lpszPatternNamescxx . . $ CSoundFile#m_lpszPatternNames. + nPat * MAX_PATTERNNAMEcxx . . $ `ext/psmplug/sndfile.h:32:9`!, cbSize); |
| 1210 | lpszName[cbSize-1] = 0; |
| 1211 | return TRUEcxx . . $ `ext/psmplug/stdafx.h:97:9`!; |
| 1212 | } |
| 1213 | return FALSEcxx . . $ `ext/psmplug/stdafx.h:93:9`!; |
| 1214 | } |
| 1215 | |
| 1216 | |
| 1217 | UINTcxx . . $ UINT# CSoundFilecxx . . $ CSoundFile#::DetectUnusedSamplescxx . . $ CSoundFile#DetectUnusedSamples(6eba86349545ae0f).(BOOLcxx . . $ BOOL# *pbIns) |
| 1218 | //----------------------------------------------- |
| 1219 | { |
| 1220 | UINTcxx . . $ UINT# nExt = 0; |
| 1221 | |
| 1222 | if (!pbIns) return 0; |
| 1223 | if (m_nInstrumentscxx . . $ CSoundFile#m_nInstruments.) |
| 1224 | { |
| 1225 | memset(pbIns, 0, MAX_SAMPLEScxx . . $ `ext/psmplug/sndfile.h:25:9`! * sizeof(BOOLcxx . . $ BOOL#)); |
| 1226 | for (UINTcxx . . $ UINT# ipat=0; ipat<MAX_PATTERNScxx . . $ `ext/psmplug/sndfile.h:24:9`!; ipat++) |
| 1227 | { |
| 1228 | MODCOMMANDcxx . . $ MODCOMMAND# *p = Patternscxx . . $ CSoundFile#Patterns.[ipat]; |
| 1229 | if (p) |
| 1230 | { |
| 1231 | UINTcxx . . $ UINT# jmax = PatternSizecxx . . $ CSoundFile#PatternSize.[ipat] * m_nChannelscxx . . $ CSoundFile#m_nChannels.; |
| 1232 | for (UINTcxx . . $ UINT# j=0; j<jmax; j++, p++) |
| 1233 | { |
| 1234 | if ((p->notecxx . . $ _MODCOMMAND#note.) && (p->notecxx . . $ _MODCOMMAND#note. <= NOTE_MAXcxx . . $ `ext/psmplug/sndfile.h:523:9`!)) |
| 1235 | { |
| 1236 | if ((p->instrcxx . . $ _MODCOMMAND#instr.) && (p->instrcxx . . $ _MODCOMMAND#instr. < MAX_INSTRUMENTScxx . . $ `ext/psmplug/sndfile.h:26:9`!)) |
| 1237 | { |
| 1238 | INSTRUMENTHEADERcxx . . $ INSTRUMENTHEADER# *penv = Headerscxx . . $ CSoundFile#Headers.[p->instrcxx . . $ _MODCOMMAND#instr.]; |
| 1239 | if (penv) |
| 1240 | { |
| 1241 | UINTcxx . . $ UINT# n = penv->Keyboardcxx . . $ _INSTRUMENTHEADER#Keyboard.[p->notecxx . . $ _MODCOMMAND#note.-1]; |
| 1242 | if (n < MAX_SAMPLEScxx . . $ `ext/psmplug/sndfile.h:25:9`!) pbIns[n] = TRUEcxx . . $ `ext/psmplug/stdafx.h:97:9`!; |
| 1243 | } |
| 1244 | } else |
| 1245 | { |
| 1246 | for (UINTcxx . . $ UINT# k=1; k<=m_nInstrumentscxx . . $ CSoundFile#m_nInstruments.; k++) |
| 1247 | { |
| 1248 | INSTRUMENTHEADERcxx . . $ INSTRUMENTHEADER# *penv = Headerscxx . . $ CSoundFile#Headers.[k]; |
| 1249 | if (penv) |
| 1250 | { |
| 1251 | UINTcxx . . $ UINT# n = penv->Keyboardcxx . . $ _INSTRUMENTHEADER#Keyboard.[p->notecxx . . $ _MODCOMMAND#note.-1]; |
| 1252 | if (n < MAX_SAMPLEScxx . . $ `ext/psmplug/sndfile.h:25:9`!) pbIns[n] = TRUEcxx . . $ `ext/psmplug/stdafx.h:97:9`!; |
| 1253 | } |
| 1254 | } |
| 1255 | } |
| 1256 | } |
| 1257 | } |
| 1258 | } |
| 1259 | } |
| 1260 | for (UINTcxx . . $ UINT# ichk=1; ichk<=m_nSamplescxx . . $ CSoundFile#m_nSamples.; ichk++) |
| 1261 | { |
| 1262 | if ((!pbIns[ichk]) && (Inscxx . . $ CSoundFile#Ins.[ichk].pSamplecxx . . $ _MODINSTRUMENT#pSample.)) nExt++; |
| 1263 | } |
| 1264 | } |
| 1265 | return nExt; |
| 1266 | } |
| 1267 | |
| 1268 | |
| 1269 | BOOLcxx . . $ BOOL# CSoundFilecxx . . $ CSoundFile#::RemoveSelectedSamplescxx . . $ CSoundFile#RemoveSelectedSamples(78ac5d2f3d401626).(BOOLcxx . . $ BOOL# *pbIns) |
| 1270 | //------------------------------------------------- |
| 1271 | { |
| 1272 | if (!pbIns) return FALSEcxx . . $ `ext/psmplug/stdafx.h:93:9`!; |
| 1273 | for (UINTcxx . . $ UINT# j=1; j<MAX_SAMPLEScxx . . $ `ext/psmplug/sndfile.h:25:9`!; j++) |
| 1274 | { |
| 1275 | if ((!pbIns[j]) && (Inscxx . . $ CSoundFile#Ins.[j].pSamplecxx . . $ _MODINSTRUMENT#pSample.)) |
| 1276 | { |
| 1277 | DestroySamplecxx . . $ CSoundFile#DestroySample(dfa6e707f7696010).(j); |
| 1278 | if ((j == m_nSamplescxx . . $ CSoundFile#m_nSamples.) && (j > 1)) m_nSamplescxx . . $ CSoundFile#m_nSamples.--; |
| 1279 | } |
| 1280 | } |
| 1281 | return TRUEcxx . . $ `ext/psmplug/stdafx.h:97:9`!; |
| 1282 | } |
| 1283 | |
| 1284 | |
| 1285 | BOOLcxx . . $ BOOL# CSoundFilecxx . . $ CSoundFile#::DestroySamplecxx . . $ CSoundFile#DestroySample(dfa6e707f7696010).(UINTcxx . . $ UINT# nSample) |
| 1286 | //------------------------------------------ |
| 1287 | { |
| 1288 | if ((!nSample) || (nSample >= MAX_SAMPLEScxx . . $ `ext/psmplug/sndfile.h:25:9`!)) return FALSEcxx . . $ `ext/psmplug/stdafx.h:93:9`!; |
| 1289 | if (!Inscxx . . $ CSoundFile#Ins.[nSample].pSamplecxx . . $ _MODINSTRUMENT#pSample.) return TRUEcxx . . $ `ext/psmplug/stdafx.h:97:9`!; |
| 1290 | MODINSTRUMENTcxx . . $ MODINSTRUMENT# *pins = &Inscxx . . $ CSoundFile#Ins.[nSample]; |
| 1291 | signed char *pSample = pins->pSamplecxx . . $ _MODINSTRUMENT#pSample.; |
| 1292 | pins->pSamplecxx . . $ _MODINSTRUMENT#pSample. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 1293 | pins->nLengthcxx . . $ _MODINSTRUMENT#nLength. = 0; |
| 1294 | pins->uFlagscxx . . $ _MODINSTRUMENT#uFlags. &= ~(CHN_16BITcxx . . $ `ext/psmplug/sndfile.h:73:9`!); |
| 1295 | for (UINTcxx . . $ UINT# i=0; i<MAX_CHANNELScxx . . $ `ext/psmplug/sndfile.h:27:9`!; i++) |
| 1296 | { |
| 1297 | if (Chncxx . . $ CSoundFile#Chn.[i].pSamplecxx . . $ _MODCHANNEL#pSample. == pSample) |
| 1298 | { |
| 1299 | Chncxx . . $ CSoundFile#Chn.[i].nPoscxx . . $ _MODCHANNEL#nPos. = Chncxx . . $ CSoundFile#Chn.[i].nLengthcxx . . $ _MODCHANNEL#nLength. = 0; |
| 1300 | Chncxx . . $ CSoundFile#Chn.[i].pSamplecxx . . $ _MODCHANNEL#pSample. = Chncxx . . $ CSoundFile#Chn.[i].pCurrentSamplecxx . . $ _MODCHANNEL#pCurrentSample. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 1301 | } |
| 1302 | } |
| 1303 | FreeSamplecxx . . $ CSoundFile#FreeSample(5d22bdacc48458e8).(pSample); |
| 1304 | return TRUEcxx . . $ `ext/psmplug/stdafx.h:97:9`!; |
| 1305 | } |