Changeset 65


Ignore:
Timestamp:
May 22, 2012, 11:31:40 AM (12 years ago)
Author:
roman
Message:
 
Location:
trunk/Utilities/GeneratePcmWavFile
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Utilities/GeneratePcmWavFile/GeneratePcmWavFile.cpp

    r27 r65  
    239239                                                for(SIZE_T nIndex = 0; nIndex < nDataSize; nIndex += pWaveFormatEx->nBlockAlign, nSampleIndex++)
    240240                                                {
     241                                                        #pragma region Per-channel Frequencies and Amplitudes
     242                                                        if(FALSE)
     243                                                        {
     244                                                                const DOUBLE pfSignalFrequencies[5] = { 1000, 1000, 1000, 1000, 1000 };
     245                                                                const DOUBLE pfSignalAmplitudes[5] = { m_fSignalAmplitude, 0, 0, 0, 0 };
     246                                                                SHORT* pnSampleData = (SHORT*) (Properties.pbBuffer + nIndex);
     247                                                                for(WORD nChannelIndex = 0; nChannelIndex < pWaveFormatEx->nChannels; nChannelIndex++)
     248                                                                {
     249                                                                        const DOUBLE fSignalPeriod = (DOUBLE) pWaveFormatEx->nSamplesPerSec / pfSignalFrequencies[nChannelIndex];
     250                                                                        const DOUBLE fSignalAmplitude = pfSignalAmplitudes[nChannelIndex];
     251                                                                        const SHORT nValue = (SHORT) (fSignalAmplitude * sin(2 * M_PI * (ThreadContext.m_nCurrentSampleIndex + nSampleIndex) / fSignalPeriod));
     252                                                                        pnSampleData[nChannelIndex] = nValue;
     253                                                                }
     254                                                                continue;
     255                                                        }
     256                                                        #pragma endregion
     257                                                        #pragma region Stream Time Coefficients
     258                                                        #if TRUE && FALSE
     259                                                        {
     260                                                                COMPILER_MESSAGE("Every 170 seconds: 50 seconds 1.0, 70 seconds 0.0, 50 seconds 1.0");
     261                                                                #pragma region Factor
     262                                                                REFERENCE_TIME nTime = ThreadContext.m_nMediaSampleTime + nIndex * (1000 * 10000i64) / pWaveFormatEx->nAvgBytesPerSec;
     263                                                                nTime /= 1000 * 10000i64;
     264                                                                // NOTE: Every 170 seconds: 50 seconds 1.0, 70 seconds 0.0, 50 seconds 1.0
     265                                                                nTime %= 170;
     266                                                                const DOUBLE fTimeFactor = (nTime < 50 || nTime >= 120) ? 1.0 : (1.0 / 256);
     267                                                                #pragma endregion
     268                                                                const SHORT nValue = (SHORT) (m_fSignalAmplitude * sin(2 * M_PI * (ThreadContext.m_nCurrentSampleIndex + nSampleIndex) / m_fSignalPeriod));
     269                                                                SHORT* pnSampleData = (SHORT*) (Properties.pbBuffer + nIndex);
     270                                                                for(WORD nChannelIndex = 0; nChannelIndex < pWaveFormatEx->nChannels; nChannelIndex++)
     271                                                                        pnSampleData[nChannelIndex] = (SHORT) (fTimeFactor * nValue);
     272                                                                continue;
     273                                                        }
     274                                                        #endif // TRUE
     275                                                        #pragma endregion
    241276                                                        const SHORT nValue = (SHORT) (m_fSignalAmplitude * sin(2 * M_PI * (ThreadContext.m_nCurrentSampleIndex + nSampleIndex) / m_fSignalPeriod));
    242277                                                        SHORT* pnSampleData = (SHORT*) (Properties.pbBuffer + nIndex);
Note: See TracChangeset for help on using the changeset viewer.