From: <sag...@us...> - 2013-04-10 20:36:04
|
Revision: 1815 http://sourceforge.net/p/modplug/code/1815 Author: saga-games Date: 2013-04-10 20:35:54 +0000 (Wed, 10 Apr 2013) Log Message: ----------- [Ref] ModChannel and ModSample sample data pointers are now void*. Modified Paths: -------------- trunk/OpenMPT/mptrack/Autotune.cpp trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/Undo.cpp trunk/OpenMPT/mptrack/Undo.h trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/test/test.cpp trunk/OpenMPT/soundlib/Fastmix.cpp trunk/OpenMPT/soundlib/ITCompression.cpp trunk/OpenMPT/soundlib/Load_ams.cpp trunk/OpenMPT/soundlib/ModChannel.h trunk/OpenMPT/soundlib/ModSample.h trunk/OpenMPT/soundlib/SampleFormatConverters.h trunk/OpenMPT/soundlib/SampleFormats.cpp trunk/OpenMPT/soundlib/SampleIO.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/modsmp_ctrl.cpp trunk/OpenMPT/soundlib/modsmp_ctrl.h Modified: trunk/OpenMPT/mptrack/Autotune.cpp =================================================================== --- trunk/OpenMPT/mptrack/Autotune.cpp 2013-04-10 20:06:25 UTC (rev 1814) +++ trunk/OpenMPT/mptrack/Autotune.cpp 2013-04-10 20:35:54 UTC (rev 1815) @@ -121,11 +121,11 @@ switch(sample.GetElementarySampleSize()) { case 1: - CopySamples(reinterpret_cast<int8 *>(sample.pSample) + sampleOffset * sample.GetNumChannels(), sampleLoopStart, sampleLoopEnd); + CopySamples(static_cast<int8 *>(sample.pSample) + sampleOffset * sample.GetNumChannels(), sampleLoopStart, sampleLoopEnd); return true; case 2: - CopySamples(reinterpret_cast<int16 *>(sample.pSample) + sampleOffset * sample.GetNumChannels(), sampleLoopStart, sampleLoopEnd); + CopySamples(static_cast<int16 *>(sample.pSample) + sampleOffset * sample.GetNumChannels(), sampleLoopStart, sampleLoopEnd); return true; } Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-04-10 20:06:25 UTC (rev 1814) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-04-10 20:35:54 UTC (rev 1815) @@ -1989,10 +1989,10 @@ ::GdiFlush(); // Send sampledata for processing. - soundtouch_putSamples(handleSt, reinterpret_cast<int16*>(sample.pSample + pos * smpsize * nChn), len); + soundtouch_putSamples(handleSt, static_cast<int16 *>(sample.pSample) + pos * nChn, len); // Receive some processed samples (it's not guaranteed that there is any available). - nLengthCounter += soundtouch_receiveSamples(handleSt, reinterpret_cast<int16*>(pNewSample) + nChn * nLengthCounter, nNewSampleLength - nLengthCounter); + nLengthCounter += soundtouch_receiveSamples(handleSt, static_cast<int16 *>(pNewSample) + nChn * nLengthCounter, nNewSampleLength - nLengthCounter); // Next buffer chunk pos += len; @@ -2002,7 +2002,7 @@ soundtouch_flush(handleSt); while(soundtouch_numSamples(handleSt) > 0 && nNewSampleLength > nLengthCounter) { - nLengthCounter += soundtouch_receiveSamples(handleSt, reinterpret_cast<int16*>(pNewSample) + nChn * nLengthCounter, nNewSampleLength - nLengthCounter); + nLengthCounter += soundtouch_receiveSamples(handleSt, static_cast<int16 *>(pNewSample) + nChn * nLengthCounter, nNewSampleLength - nLengthCounter); } soundtouch_clear(handleSt); ASSERT(soundtouch_isEmpty(handleSt) != 0); @@ -2789,7 +2789,7 @@ if ((IsLocked()) || (!m_pSndFile)) return; UINT pinc = 1; ModSample &sample = m_pSndFile->GetSample(m_nSample); - LPSTR pSample = sample.pSample; + const uint8 *pSample = static_cast<const uint8 *>(sample.pSample); short int pos; bool redraw = false; @@ -2805,7 +2805,7 @@ if ((pos = (short int)m_SpinLoopStart.GetPos()) != 0) { bool bOk = false; - LPSTR p = pSample+sample.nLoopStart*pinc; + const uint8 *p = pSample + sample.nLoopStart * pinc; int find0 = (int)pSample[sample.nLoopEnd*pinc-pinc]; int find1 = (int)pSample[sample.nLoopEnd*pinc]; // Find Next LoopStart Point @@ -2851,7 +2851,7 @@ if ((pos) && (sample.nLoopEnd)) { bool bOk = false; - LPSTR p = pSample+sample.nLoopEnd*pinc; + const uint8 *p = pSample + sample.nLoopEnd * pinc; int find0 = (int)pSample[sample.nLoopStart*pinc]; int find1 = (int)pSample[sample.nLoopStart*pinc+pinc]; // Find Next LoopEnd Point @@ -2896,7 +2896,7 @@ if ((pos) && (sample.nSustainEnd)) { bool bOk = false; - LPSTR p = pSample+sample.nSustainStart*pinc; + const uint8 *p = pSample + sample.nSustainStart * pinc; int find0 = (int)pSample[sample.nSustainEnd*pinc-pinc]; int find1 = (int)pSample[sample.nSustainEnd*pinc]; // Find Next Sustain LoopStart Point @@ -2941,7 +2941,7 @@ if (pos) { bool bOk = false; - LPSTR p = pSample+sample.nSustainEnd*pinc; + const uint8 *p = pSample + sample.nSustainEnd * pinc; int find0 = (int)pSample[sample.nSustainStart*pinc]; int find1 = (int)pSample[sample.nSustainStart*pinc+pinc]; // Find Next LoopEnd Point Modified: trunk/OpenMPT/mptrack/Undo.cpp =================================================================== --- trunk/OpenMPT/mptrack/Undo.cpp 2013-04-10 20:06:25 UTC (rev 1814) +++ trunk/OpenMPT/mptrack/Undo.cpp 2013-04-10 20:35:54 UTC (rev 1815) @@ -327,7 +327,7 @@ undo.samplePtr = sndFile.AllocateSample((changeLen + 4) * bytesPerSample); if(undo.samplePtr == nullptr) return false; - memcpy(undo.samplePtr, oldSample.pSample + changeStart * bytesPerSample, changeLen * bytesPerSample); + memcpy(undo.samplePtr, static_cast<const char *>(oldSample.pSample) + changeStart * bytesPerSample, changeLen * bytesPerSample); #ifdef _DEBUG char s[64]; @@ -364,8 +364,8 @@ UndoInfo &undo = UndoBuffer[smp - 1].back(); ModSample &sample = sndFile.GetSample(smp); - LPSTR pCurrentSample = sample.pSample; - LPSTR pNewSample = nullptr; // a new sample is possibly going to be allocated, depending on what's going to be undone. + char *pCurrentSample = static_cast<char *>(sample.pSample); + char *pNewSample = nullptr; // a new sample is possibly going to be allocated, depending on what's going to be undone. bool replace = false; uint8 bytesPerSample = undo.OldSample.GetBytesPerSample(); @@ -407,7 +407,7 @@ case sundo_delete: // insert deleted data - pNewSample = sndFile.AllocateSample(undo.OldSample.GetSampleSizeInBytes() + 4 * bytesPerSample); + pNewSample = static_cast<char *>(sndFile.AllocateSample(undo.OldSample.GetSampleSizeInBytes() + 4 * bytesPerSample)); if(pNewSample == nullptr) return false; replace = true; memcpy(pNewSample, pCurrentSample, undo.changeStart * bytesPerSample); @@ -417,7 +417,7 @@ case sundo_replace: // simply exchange sample pointer - pNewSample = undo.samplePtr; + pNewSample = static_cast<char *>(undo.samplePtr); undo.samplePtr = nullptr; // prevent sample from being deleted replace = true; break; Modified: trunk/OpenMPT/mptrack/Undo.h =================================================================== --- trunk/OpenMPT/mptrack/Undo.h 2013-04-10 20:06:25 UTC (rev 1814) +++ trunk/OpenMPT/mptrack/Undo.h 2013-04-10 20:35:54 UTC (rev 1815) @@ -112,7 +112,7 @@ { ModSample OldSample; char oldName[MAX_SAMPLENAME]; - LPSTR samplePtr; + void *samplePtr; SmpLength changeStart, changeEnd; sampleUndoTypes changeType; }; Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2013-04-10 20:06:25 UTC (rev 1814) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2013-04-10 20:35:54 UTC (rev 1815) @@ -1268,7 +1268,7 @@ void CViewSample::SetInitialDrawPoint(void *pSample, const CPoint &point) //----------------------------------------------------------------------- { - T* data = reinterpret_cast<T*>(pSample); + T* data = static_cast<T *>(pSample); data[m_dwEndDrag] = GetSampleValueFromPoint<T, uT>(point); } @@ -1277,7 +1277,7 @@ void CViewSample::SetSampleData(void *pSample, const CPoint &point, const DWORD old) //---------------------------------------------------------------------------------- { - T* data = reinterpret_cast<T*>(pSample); + T* data = static_cast<T *>(pSample); const int oldvalue = data[old]; const int value = GetSampleValueFromPoint<T, uT>(point); for(DWORD i=old; i != m_dwEndDrag; i += (m_dwEndDrag > old ? 1 : -1)) @@ -1820,7 +1820,7 @@ sample.nLength -= cutlen; cutlen *= sample.GetBytesPerSample(); - LPSTR p = sample.pSample; + char *p = static_cast<char *>(sample.pSample); for (UINT i=istart; i<iend; i++) { p[i] = (i+cutlen < iend) ? p[i+cutlen] : (char)0; @@ -1909,7 +1909,7 @@ pdata->length = dwSmpLen; phdr->filesize += pdata->length; LPBYTE psamples = p + sizeof(WAVEFILEHEADER) + sizeof(WAVEFORMATHEADER) + sizeof(WAVEDATAHEADER); - memcpy(psamples, sample.pSample+dwSmpOffset, dwSmpLen); + memcpy(psamples, static_cast<const char *>(sample.pSample) + dwSmpOffset, dwSmpLen); if (pfmt->bitspersample == 8) { for (UINT i = 0; i < dwSmpLen; i++) psamples[i] += 0x80; Modified: trunk/OpenMPT/mptrack/test/test.cpp =================================================================== --- trunk/OpenMPT/mptrack/test/test.cpp 2013-04-10 20:06:25 UTC (rev 1814) +++ trunk/OpenMPT/mptrack/test/test.cpp 2013-04-10 20:35:54 UTC (rev 1815) @@ -629,7 +629,7 @@ // Sample Data (Stereo Interleaved) for(size_t i = 0; i < 7; i++) { - VERIFY_EQUAL_NONCONT(reinterpret_cast<int16 *>(sample.pSample)[4 + i], int16(-32768)); + VERIFY_EQUAL_NONCONT(static_cast<int16 *>(sample.pSample)[4 + i], int16(-32768)); } } @@ -861,7 +861,7 @@ // Sample Data (Stereo Interleaved) for(size_t i = 0; i < 7; i++) { - VERIFY_EQUAL_NONCONT(reinterpret_cast<int16 *>(sample.pSample)[4 + i], int16(-32768)); + VERIFY_EQUAL_NONCONT(static_cast<int16 *>(sample.pSample)[4 + i], int16(-32768)); } } @@ -1314,7 +1314,7 @@ for(size_t i = 0; i < 65536; i++) { - int16 normValue = reinterpret_cast<const int16 *>(sample.pSample)[i]; + int16 normValue = static_cast<const int16 *>(sample.pSample)[i]; if(abs(normValue - static_cast<int16>(i - 0x8000u)) > 1) { VERIFY_EQUAL_NONCONT(true, false); @@ -1348,7 +1348,7 @@ for(size_t i = 0; i < 65536; i++) { - int16 normValue = reinterpret_cast<const int16 *>(sample.pSample)[i]; + int16 normValue = static_cast<const int16 *>(sample.pSample)[i]; if(abs(normValue - static_cast<int16>(i- 0x8000u)) > 1) { VERIFY_EQUAL_NONCONT(true, false); Modified: trunk/OpenMPT/soundlib/Fastmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Fastmix.cpp 2013-04-10 20:06:25 UTC (rev 1814) +++ trunk/OpenMPT/soundlib/Fastmix.cpp 2013-04-10 20:35:54 UTC (rev 1815) @@ -46,7 +46,7 @@ #define SNDMIX_BEGINSAMPLELOOP8\ register ModChannel * const pChn = pChannel;\ nPos = pChn->nPosLo;\ - const signed char *p = (signed char *)(pChn->pCurrentSample+pChn->nPos);\ + const signed char *p = (signed char *)(pChn->pCurrentSample)+pChn->nPos;\ if (pChn->dwFlags[CHN_STEREO]) p += pChn->nPos;\ int *pvol = pbuffer;\ do { @@ -54,7 +54,7 @@ #define SNDMIX_BEGINSAMPLELOOP16\ register ModChannel * const pChn = pChannel;\ nPos = pChn->nPosLo;\ - const signed short *p = (signed short *)(pChn->pCurrentSample+(pChn->nPos*2));\ + const signed short *p = (signed short *)(pChn->pCurrentSample)+pChn->nPos;\ if (pChn->dwFlags[CHN_STEREO]) p += pChn->nPos;\ int *pvol = pbuffer;\ do { Modified: trunk/OpenMPT/soundlib/ITCompression.cpp =================================================================== --- trunk/OpenMPT/soundlib/ITCompression.cpp 2013-04-10 20:06:25 UTC (rev 1814) +++ trunk/OpenMPT/soundlib/ITCompression.cpp 2013-04-10 20:35:54 UTC (rev 1815) @@ -69,9 +69,9 @@ byteVal = 0; if(mptSample.GetElementarySampleSize() > 1) - Compress<IT16BitParams>(sample.pSample + 2 * chn, offset, remain); + Compress<IT16BitParams>(static_cast<int16 *>(sample.pSample) + chn, offset, remain); else - Compress<IT8BitParams>(sample.pSample + chn, offset, remain); + Compress<IT8BitParams>(static_cast<int8 *>(sample.pSample) + chn, offset, remain); if(file) fwrite(&packedData[0], packedLength, 1, file); packedTotalLength += packedLength; @@ -362,9 +362,9 @@ mem1 = mem2 = 0; if(mptSample.GetElementarySampleSize() > 1) - Uncompress<IT16BitParams>(mptSample.pSample + 2 * chn); + Uncompress<IT16BitParams>(static_cast<int16 *>(mptSample.pSample) + chn); else - Uncompress<IT8BitParams>(mptSample.pSample + chn); + Uncompress<IT8BitParams>(static_cast<int8 *>(mptSample.pSample) + chn); } } } Modified: trunk/OpenMPT/soundlib/Load_ams.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_ams.cpp 2013-04-10 20:06:25 UTC (rev 1814) +++ trunk/OpenMPT/soundlib/Load_ams.cpp 2013-04-10 20:35:54 UTC (rev 1815) @@ -959,7 +959,7 @@ ///////////////////////////////////////////////////////////////////// // AMS Sample unpacking -void AMSUnpack(const char * const source, size_t sourceSize, char * const dest, const size_t destSize, char packCharacter) +void AMSUnpack(const char * const source, size_t sourceSize, void * const dest, const size_t destSize, char packCharacter) //------------------------------------------------------------------------------------------------------------------------ { int8 *tempBuf = new (std::nothrow) int8[destSize]; @@ -1008,6 +1008,7 @@ int8 *out = tempBuf; uint16 bitcount = 0x80; size_t k = 0; + uint8 *dst = static_cast<uint8 *>(dest); for(size_t i = 0; i < destSize; i++) { uint8 al = *out++; @@ -1017,7 +1018,7 @@ uint16 bl = al & bitcount; bl = ((bl | (bl << 8)) >> ((dh + 8 - count) & 7)) & 0xFF; bitcount = ((bitcount | (bitcount << 8)) >> 1) & 0xFF; - dest[k++] |= bl; + dst[k++] |= bl; if(k >= destSize) { k = 0; @@ -1031,7 +1032,7 @@ // Delta Unpack { int8 old = 0; - int8 *out = dest; + int8 *out = static_cast<int8 *>(dest); for(size_t i = destSize; i != 0; i--) { int pos = *reinterpret_cast<uint8 *>(out); Modified: trunk/OpenMPT/soundlib/ModChannel.h =================================================================== --- trunk/OpenMPT/soundlib/ModChannel.h 2013-04-10 20:06:25 UTC (rev 1814) +++ trunk/OpenMPT/soundlib/ModChannel.h 2013-04-10 20:35:54 UTC (rev 1815) @@ -30,11 +30,11 @@ }; // Information used in the mixer (should be kept tight for better caching) - LPSTR pCurrentSample; // Currently playing sample (nullptr if no sample is playing) - uint32 nPos; - uint32 nPosLo; // actually 16-bit (fractional part) - int32 nInc; // 16.16 fixed point - int32 nRightVol; + const void *pCurrentSample; // Currently playing sample (nullptr if no sample is playing) + uint32 nPos; // Current play position + uint32 nPosLo; // 16-bit fractional part of play position + int32 nInc; // 16.16 fixed point sample speed relative to mixing frequency (0x10000 = one sample per output sample, 0x20000 = two samples per output sample, etc...) + int32 nRightVol; // This is actually LEFT! >:( FIX THIS! int32 nLeftVol; int32 nRightRamp; int32 nLeftRamp; @@ -54,9 +54,9 @@ // Information not used in the mixer FlagSet<ChannelFlags> dwOldFlags; // Flags from previous tick - LPSTR pSample; // Currently playing sample, or previously played sample if no sample is playing. - ModSample *pModSample; // Currently assigned sample slot - ModInstrument *pModInstrument; // Currently assigned instrument slot + const void *pSample; // Currently playing sample, or previously played sample if no sample is playing. + ModSample *pModSample; // Currently assigned sample slot + ModInstrument *pModInstrument; // Currently assigned instrument slot int32 nNewRightVol, nNewLeftVol; int32 nRealVolume, nRealPan; int32 nVolume, nPan, nFadeOutVol; @@ -102,10 +102,25 @@ ModCommand rowCommand; //NOTE_PCs memory. + float m_plugParamValueStep, m_plugParamTargetValue; uint16 m_RowPlugParam; - float m_plugParamValueStep, m_plugParamTargetValue; PLUGINDEX m_RowPlug; + //-->Variables used to make user-definable tuning modes work with pattern effects. + int32 m_PortamentoFineSteps, m_PortamentoTickSlide; + + uint32 m_Freq; + float m_VibratoDepth; + + //If true, freq should be recalculated in ReadNote() on first tick. + //Currently used only for vibrato things - using in other context might be + //problematic. + bool m_ReCalculateFreqOnFirstTick; + + //To tell whether to calculate frequency. + bool m_CalculateFreq; + //<---- + void ClearRowCmd() { rowCommand = ModCommand::Empty(); } // Get a reference to a specific envelope of this channel @@ -152,22 +167,6 @@ // Check if the channel has a valid MIDI output. This function guarantees that pModInstrument != nullptr. bool HasMIDIOutput() const { return pModInstrument != nullptr && pModInstrument->HasValidMIDIChannel(); } - //-->Variables used to make user-definable tuning modes work with pattern effects. - bool m_ReCalculateFreqOnFirstTick; - //If true, freq should be recalculated in ReadNote() on first tick. - //Currently used only for vibrato things - using in other context might be - //problematic. - - bool m_CalculateFreq; - //To tell whether to calculate frequency. - - int32 m_PortamentoFineSteps; - long m_PortamentoTickSlide; - - uint32 m_Freq; - float m_VibratoDepth; - //<---- - ModChannel() { memset(this, 0, sizeof(*this)); Modified: trunk/OpenMPT/soundlib/ModSample.h =================================================================== --- trunk/OpenMPT/soundlib/ModSample.h 2013-04-10 20:06:25 UTC (rev 1814) +++ trunk/OpenMPT/soundlib/ModSample.h 2013-04-10 20:35:54 UTC (rev 1815) @@ -16,7 +16,7 @@ SmpLength nLength; // In samples, not bytes SmpLength nLoopStart, nLoopEnd; // Dito SmpLength nSustainStart, nSustainEnd; // Dito - LPSTR pSample; // Pointer to sample data + void *pSample; // Pointer to sample data uint32 nC5Speed; // Frequency of middle-C, in Hz (for IT/S3M/MPTM) uint16 nPan; // Default sample panning (if pan flag is set) uint16 nVolume; // Default volume Modified: trunk/OpenMPT/soundlib/SampleFormatConverters.h =================================================================== --- trunk/OpenMPT/soundlib/SampleFormatConverters.h 2013-04-10 20:06:25 UTC (rev 1814) +++ trunk/OpenMPT/soundlib/SampleFormatConverters.h 2013-04-10 20:35:54 UTC (rev 1815) @@ -364,7 +364,7 @@ // Read left channel CopySample<SampleConversion>(sample.pSample, sample.nLength, 2, sourceBuffer, sourceSize, 2); // Read right channel - return CopySample<SampleConversion>(sample.pSample + sizeof(SampleConversion::output_t), sample.nLength, 2, sourceBuffer + rightOffset, sourceSize - rightOffset, 2); + return CopySample<SampleConversion>(static_cast<SampleConversion::output_t *>(sample.pSample), sample.nLength, 2, sourceBuffer + rightOffset, sourceSize - rightOffset, 2); } else { // This is quicker (and smaller), but only possible if the functor doesn't care about what it actually processes: @@ -393,7 +393,7 @@ } else { // Read right channel - return rightOffset + CopySample<SampleConversion>(sample.pSample + sizeof(SampleConversion::output_t), sample.nLength, 2, sourceBuffer + rightOffset, sourceSize - rightOffset, 1); + return rightOffset + CopySample<SampleConversion>(static_cast<SampleConversion::output_t *>(sample.pSample) + 1, sample.nLength, 2, sourceBuffer + rightOffset, sourceSize - rightOffset, 1); } } @@ -401,7 +401,7 @@ // Copy a sample data buffer and normalize it. Requires slightly advanced sample conversion functor. template<typename SampleConversion> size_t CopyAndNormalizeSample(ModSample &sample, const uint8 *sourceBuffer, size_t sourceSize) -//------------------------------------------------------------------------------------------ +//-------------------------------------------------------------------------------------------- { static_assert(SampleConversion::hasState == false, "Implementation of this conversion function is stateless"); const size_t inSize = sizeof(SampleConversion::input_t); @@ -426,7 +426,7 @@ if(!sampleConv.IsSilent()) { // Copying buffer. - SampleConversion::output_t *outBuf = reinterpret_cast<SampleConversion::output_t *>(sample.pSample); + SampleConversion::output_t *outBuf = static_cast<SampleConversion::output_t *>(sample.pSample); inBuf = reinterpret_cast<const SampleConversion::input_t *>(sourceBuffer); for(size_t i = numSamples; i != 0; i--) Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-04-10 20:06:25 UTC (rev 1814) +++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-04-10 20:35:54 UTC (rev 1815) @@ -1936,8 +1936,8 @@ // Source bit depth const unsigned int bps = frame->header.bits_per_sample; - int8 *sampleData8 = reinterpret_cast<int8 *>(sample.pSample) + offset; - int16 *sampleData16 = reinterpret_cast<int16 *>(sample.pSample) + offset; + int8 *sampleData8 = static_cast<int8 *>(sample.pSample) + offset; + int16 *sampleData16 = static_cast<int16 *>(sample.pSample) + offset; ASSERT((bps <= 8 && sample.GetElementarySampleSize() == 1) || (bps > 8 && sample.GetElementarySampleSize() == 2)); ASSERT(modChannels <= FLAC__stream_decoder_get_channels(decoder)); @@ -2378,7 +2378,7 @@ Samples[sample].AllocateSample(); size_t ndecoded; - mpg123_read(mh, reinterpret_cast<unsigned char*>(Samples[sample].pSample), Samples[sample].GetSampleSizeInBytes(), &ndecoded); + mpg123_read(mh, static_cast<unsigned char *>(Samples[sample].pSample), Samples[sample].GetSampleSizeInBytes(), &ndecoded); mpg123_delete(mh); if(Samples[sample].pSample != nullptr) Modified: trunk/OpenMPT/soundlib/SampleIO.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleIO.cpp 2013-04-10 20:06:25 UTC (rev 1814) +++ trunk/OpenMPT/soundlib/SampleIO.cpp 2013-04-10 20:35:54 UTC (rev 1815) @@ -18,7 +18,7 @@ // External decompressors -extern void AMSUnpack(const char * const source, size_t sourceSize, char * const dest, const size_t destSize, char packCharacter); +extern void AMSUnpack(const char * const source, size_t sourceSize, void * const dest, const size_t destSize, char packCharacter); extern uint16 MDLReadBits(uint32 &bitbuf, uint32 &bitnum, const uint8 *(&ibuf), int8 n); extern int DMFUnpack(LPBYTE psample, const uint8 *ibuf, const uint8 *ibufmax, uint32 maxlen); @@ -269,7 +269,7 @@ LimitMax(readLength, file.BytesLeft()); const uint8 *inBuf = sourceBuf + sizeof(compressionTable); - int8 *outBuf = sample.pSample; + int8 *outBuf = static_cast<int8 *>(sample.pSample); int8 delta = 0; for(size_t i = readLength; i != 0; i--) @@ -312,8 +312,8 @@ { uint32 bitBuf = file.ReadUint32LE(), bitNum = 32; - uint8 *outBuf8 = reinterpret_cast<uint8 *>(sample.pSample); - uint16 *outBuf16 = reinterpret_cast<uint16 *>(sample.pSample); + uint8 *outBuf8 = static_cast<uint8 *>(sample.pSample); + uint16 *outBuf16 = static_cast<uint16 *>(sample.pSample); const uint8 *inBuf = sourceBuf + 4; uint8 dlt = 0, lowbyte = 0; @@ -355,7 +355,7 @@ { const uint8 *inBuf = sourceBuf; const uint8 *inBufMax = inBuf + fileSize; - uint8 *outBuf = reinterpret_cast<uint8 *>(sample.pSample); + uint8 *outBuf = static_cast<uint8 *>(sample.pSample); bytesRead = DMFUnpack(outBuf, inBuf, inBufMax, sample.GetSampleSizeInBytes()); } } Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-04-10 20:06:25 UTC (rev 1814) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-04-10 20:35:54 UTC (rev 1815) @@ -1302,7 +1302,6 @@ { ModChannel *pChn = &Chn[nChn]; ModInstrument *pIns = nullptr; - LPSTR pSample; if(!ModCommand::IsNote(note)) { return; @@ -1333,7 +1332,7 @@ return; } if(instr >= MAX_INSTRUMENTS) instr = 0; - pSample = pChn->pSample; + const void *pSample = pChn->pSample; pIns = pChn->pModInstrument; if(instr && note) { @@ -3637,7 +3636,8 @@ pChn->nEFxOffset = 0; // TRASH IT!!! (Yes, the sample!) - pModSample->pSample[pModSample->nLoopStart + pChn->nEFxOffset] = ~pModSample->pSample[pModSample->nLoopStart + pChn->nEFxOffset]; + uint8 &sample = static_cast<uint8 *>(pModSample->pSample)[pModSample->nLoopStart + pChn->nEFxOffset]; + sample = ~sample; //AdjustSampleLoop(pModSample); } Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-04-10 20:06:25 UTC (rev 1814) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-04-10 20:35:54 UTC (rev 1815) @@ -854,7 +854,7 @@ // Memory Allocation // Allocate sample memory. On sucess, a pointer to the silenced sample buffer is returned. On failure, nullptr is returned. -LPSTR CSoundFile::AllocateSample(UINT nbytes) +void *CSoundFile::AllocateSample(UINT nbytes) //------------------------------------------- { if(nbytes > SIZE_MAX - 0x29u) @@ -1320,7 +1320,7 @@ template<typename T> void AdjustSampleLoopImpl(ModSample &sample) { - T *data = reinterpret_cast<T *>(sample.pSample); + T *data = static_cast<T *>(sample.pSample); SmpLength numSamples = sample.nLength; // Adjust end of sample Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-04-10 20:06:25 UTC (rev 1814) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-04-10 20:35:54 UTC (rev 1815) @@ -673,7 +673,7 @@ // System-Dependant functions public: - static LPSTR AllocateSample(UINT nbytes); + static void *AllocateSample(UINT nbytes); static void FreeSample(void *p); ModInstrument *AllocateInstrument(INSTRUMENTINDEX instr, SAMPLEINDEX assignedSample = 0); Modified: trunk/OpenMPT/soundlib/modsmp_ctrl.cpp =================================================================== --- trunk/OpenMPT/soundlib/modsmp_ctrl.cpp 2013-04-10 20:06:25 UTC (rev 1814) +++ trunk/OpenMPT/soundlib/modsmp_ctrl.cpp 2013-04-10 20:35:54 UTC (rev 1815) @@ -19,10 +19,10 @@ namespace ctrlSmp { -void ReplaceSample(ModSample &smp, const LPSTR pNewSample, const SmpLength nNewLength, CSoundFile &sndFile) -//--------------------------------------------------------------------------------------------------------- +void ReplaceSample(ModSample &smp, void *pNewSample, const SmpLength nNewLength, CSoundFile &sndFile) +//--------------------------------------------------------------------------------------------------- { - LPSTR const pOldSmp = smp.pSample; + void * const pOldSmp = smp.pSample; FlagSet<ChannelFlags> setFlags, resetFlags; setFlags.set(CHN_16BIT, smp.uFlags[CHN_16BIT]); @@ -51,7 +51,7 @@ const SmpLength nNewSmpBytes = nOldBytes + nSilenceBytes; const SmpLength nNewLength = smp.nLength + nSilenceLength; - LPSTR pNewSmp = 0; + char *pNewSmp = nullptr; #if 0 if( GetSampleCapacity(smp) >= nNewSmpBytes ) // If sample has room to expand. { @@ -62,7 +62,7 @@ else // Have to allocate new sample. #endif { - pNewSmp = CSoundFile::AllocateSample(nNewSmpBytes); + pNewSmp = static_cast<char *>(CSoundFile::AllocateSample(nNewSmpBytes)); if(pNewSmp == 0) return smp.nLength; //Sample allocation failed. if(nStartFrom == 0) @@ -111,9 +111,9 @@ const SmpLength nNewSmpBytes = nNewLength * smp.GetBytesPerSample(); - LPSTR pNewSmp = 0; + void *pNewSmp = nullptr; pNewSmp = CSoundFile::AllocateSample(nNewSmpBytes); - if(pNewSmp == 0) + if(pNewSmp == nullptr) return smp.nLength; //Sample allocation failed. // Copy over old data and replace sample by the new one @@ -149,7 +149,7 @@ { ModSample* const pSmp = &smp; const UINT len = pSmp->nLength; - T *p = reinterpret_cast<T *>(pSmp->pSample); + T *p = static_cast<T *>(pSmp->pSample); if (pSmp->uFlags & CHN_STEREO) { p[(len+3)*2] = p[(len+2)*2] = p[(len+1)*2] = p[(len)*2] = p[(len-1)*2]; @@ -379,9 +379,9 @@ // step 1: Calculate offset. OffsetData oData = {0,0,0}; if(smp.GetElementarySampleSize() == 2) - oData = CalculateOffset(reinterpret_cast<int16*>(smp.pSample) + iStart, iEnd - iStart); + oData = CalculateOffset(static_cast<int16 *>(smp.pSample) + iStart, iEnd - iStart); else if(smp.GetElementarySampleSize() == 1) - oData = CalculateOffset(reinterpret_cast<int8*>(smp.pSample) + iStart, iEnd - iStart); + oData = CalculateOffset(static_cast<int8*>(smp.pSample) + iStart, iEnd - iStart); double dMin = oData.dMin, dMax = oData.dMax, dOffset = oData.dOffset; @@ -400,9 +400,9 @@ // step 2: centralize + normalize sample dOffset *= dMaxAmplitude * dAmplify; if(smp.GetElementarySampleSize() == 2) - RemoveOffsetAndNormalize( reinterpret_cast<int16*>(smp.pSample) + iStart, iEnd - iStart, dOffset, dAmplify); + RemoveOffsetAndNormalize( static_cast<int16 *>(smp.pSample) + iStart, iEnd - iStart, dOffset, dAmplify); else if(smp.GetElementarySampleSize() == 1) - RemoveOffsetAndNormalize( reinterpret_cast<int8*>(smp.pSample) + iStart, iEnd - iStart, dOffset, dAmplify); + RemoveOffsetAndNormalize( static_cast<int8 *>(smp.pSample) + iStart, iEnd - iStart, dOffset, dAmplify); // step 3: adjust global vol (if available) if((modtype & (MOD_TYPE_IT | MOD_TYPE_MPT)) && (iStart == 0) && (iEnd == smp.nLength * smp.GetNumChannels())) @@ -449,13 +449,13 @@ if(iEnd - iStart < 2) return false; if(smp.GetBytesPerSample() == 8) // unused (yet) - ReverseSampleImpl(reinterpret_cast<int64*>(smp.pSample) + iStart, iEnd - iStart); + ASSERT(false); //ReverseSampleImpl(static_cast<int64 *>(smp.pSample) + iStart, iEnd - iStart); else if(smp.GetBytesPerSample() == 4) // 16 bit stereo - ReverseSampleImpl(reinterpret_cast<int32*>(smp.pSample) + iStart, iEnd - iStart); + ReverseSampleImpl(static_cast<int32 *>(smp.pSample) + iStart, iEnd - iStart); else if(smp.GetBytesPerSample() == 2) // 16 bit mono / 8 bit stereo - ReverseSampleImpl(reinterpret_cast<int16*>(smp.pSample) + iStart, iEnd - iStart); + ReverseSampleImpl(static_cast<int16 *>(smp.pSample) + iStart, iEnd - iStart); else if(smp.GetBytesPerSample() == 1) // 8 bit mono - ReverseSampleImpl(reinterpret_cast<int8*>(smp.pSample) + iStart, iEnd - iStart); + ReverseSampleImpl(static_cast<int8 *>(smp.pSample) + iStart, iEnd - iStart); else return false; @@ -488,9 +488,9 @@ iStart *= smp.GetNumChannels(); iEnd *= smp.GetNumChannels(); if(smp.GetElementarySampleSize() == 2) - UnsignSampleImpl(reinterpret_cast<int16*>(smp.pSample) + iStart, iEnd - iStart); + UnsignSampleImpl(static_cast<int16 *>(smp.pSample) + iStart, iEnd - iStart); else if(smp.GetElementarySampleSize() == 1) - UnsignSampleImpl(reinterpret_cast<int8*>(smp.pSample) + iStart, iEnd - iStart); + UnsignSampleImpl(static_cast<int8 *>(smp.pSample) + iStart, iEnd - iStart); else return false; @@ -522,9 +522,9 @@ iStart *= smp.GetNumChannels(); iEnd *= smp.GetNumChannels(); if(smp.GetElementarySampleSize() == 2) - InvertSampleImpl(reinterpret_cast<int16*>(smp.pSample) + iStart, iEnd - iStart); + InvertSampleImpl(static_cast<int16 *>(smp.pSample) + iStart, iEnd - iStart); else if(smp.GetElementarySampleSize() == 1) - InvertSampleImpl(reinterpret_cast<int8*>(smp.pSample) + iStart, iEnd - iStart); + InvertSampleImpl(static_cast<int8 *>(smp.pSample) + iStart, iEnd - iStart); else return false; @@ -570,9 +570,9 @@ if(smp.pSample == nullptr || smpCount == 0) return false; if(smp.GetElementarySampleSize() == 2) - return EnableSmartSampleRampingImpl(reinterpret_cast<int16*>(smp.pSample) + sampleOffset, smpCount); + return EnableSmartSampleRampingImpl(static_cast<int16 *>(smp.pSample) + sampleOffset, smpCount); else if(smp.GetElementarySampleSize() == 1) - return EnableSmartSampleRampingImpl(reinterpret_cast<int8*>(smp.pSample) + sampleOffset, smpCount); + return EnableSmartSampleRampingImpl(static_cast<int8 *>(smp.pSample) + sampleOffset, smpCount); else return false; } @@ -604,9 +604,9 @@ iFadeLength *= smp.GetNumChannels(); if(smp.GetElementarySampleSize() == 2) - XFadeSampleImpl(reinterpret_cast<int16*>(smp.pSample) + iStart, iEnd - iStart, iFadeLength); + XFadeSampleImpl(static_cast<int16 *>(smp.pSample) + iStart, iEnd - iStart, iFadeLength); else if(smp.GetElementarySampleSize() == 1) - XFadeSampleImpl(reinterpret_cast<int8*>(smp.pSample) + iStart, iEnd - iStart, iFadeLength); + XFadeSampleImpl(static_cast<int8 *>(smp.pSample) + iStart, iEnd - iStart, iFadeLength); else return false; @@ -649,9 +649,9 @@ if(conversionMode == mixChannels) { if(smp.GetElementarySampleSize() == 2) - ConvertStereoToMonoMixImpl(reinterpret_cast<int16 *>(smp.pSample), smp.nLength); + ConvertStereoToMonoMixImpl(static_cast<int16 *>(smp.pSample), smp.nLength); else if(smp.GetElementarySampleSize() == 1) - ConvertStereoToMonoMixImpl(reinterpret_cast<int8 *>(smp.pSample), smp.nLength); + ConvertStereoToMonoMixImpl(static_cast<int8 *>(smp.pSample), smp.nLength); else return false; } else @@ -661,9 +661,9 @@ conversionMode = onlyLeft; } if(smp.GetElementarySampleSize() == 2) - ConvertStereoToMonoOneChannelImpl(reinterpret_cast<int16 *>(smp.pSample) + (conversionMode == onlyLeft ? 0 : 1), smp.nLength); + ConvertStereoToMonoOneChannelImpl(static_cast<int16 *>(smp.pSample) + (conversionMode == onlyLeft ? 0 : 1), smp.nLength); else if(smp.GetElementarySampleSize() == 1) - ConvertStereoToMonoOneChannelImpl(reinterpret_cast<int8 *>(smp.pSample) + (conversionMode == onlyLeft ? 0 : 1), smp.nLength); + ConvertStereoToMonoOneChannelImpl(static_cast<int8 *>(smp.pSample) + (conversionMode == onlyLeft ? 0 : 1), smp.nLength); else return false; } @@ -691,8 +691,8 @@ { void ReplaceSample( ModChannel (&Chn)[MAX_CHANNELS], - LPCSTR pOldSample, - LPSTR pNewSample, + const void * const pOldSample, + const void * const pNewSample, const SmpLength nNewLength, FlagSet<ChannelFlags> setFlags, FlagSet<ChannelFlags> resetFlags) Modified: trunk/OpenMPT/soundlib/modsmp_ctrl.h =================================================================== --- trunk/OpenMPT/soundlib/modsmp_ctrl.h 2013-04-10 20:06:25 UTC (rev 1814) +++ trunk/OpenMPT/soundlib/modsmp_ctrl.h 2013-04-10 20:35:54 UTC (rev 1815) @@ -37,7 +37,7 @@ SmpLength ResizeSample(ModSample &smp, const SmpLength nNewLength, CSoundFile &sndFile); // Replaces sample in 'smp' with given sample and frees the old sample. -void ReplaceSample(ModSample &smp, const LPSTR pNewSample, const SmpLength nNewLength, CSoundFile &sndFile); +void ReplaceSample(ModSample &smp, void *pNewSample, const SmpLength nNewLength, CSoundFile &sndFile); bool AdjustEndOfSample(ModSample &smp, CSoundFile &sndFile); @@ -93,8 +93,8 @@ // Replaces sample from sound channels by given sample. void ReplaceSample( ModChannel (&Chn)[MAX_CHANNELS], - LPCSTR pOldSample, - LPSTR pNewSample, + const void * const pOldSample, + const void * const pNewSample, const SmpLength nNewLength, FlagSet<ChannelFlags> setFlags, FlagSet<ChannelFlags> resetFlags); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |