void __fastcall TFrameThread::Execute()
{

	while(!Terminated) {
		_clearfp();
//	printf("          %d\n", bmpQueue->size());
		if(!bmpQueue->empty()) {
			BITMAP * aBmp = NULL;
			unsigned int res = WaitForSingleObject(hMutex,INFINITE);
			if (res!=WAIT_OBJECT_0) {ReleaseMutex(hMutex);continue;}
			__try
			{
				aBmp = bmpQueue->front();
				bmpQueue->pop();
			}
			__finally
			{
				ReleaseMutex(hMutex);

			}

  			MainCaptureForm->DoFrame(aBmp);

			destroy_bitmap(aBmp);


		} else {
Beispiel #2
0
 ~fpu_reset_guard() {
 #if defined(_MSC_VER)
     _clearfp(); // For MSVC, clear the floating point error flags
 #elif defined(FE_ALL_EXCEPT)
     feclearexcept(FE_ALL_EXCEPT);
 #endif
 }
Beispiel #3
0
void EnableFPE()
{
	// clear any outstanding exceptions before enabling, otherwise they'll
	// trip immediately
	_clearfp();
	_controlfp(_EM_INEXACT | _EM_UNDERFLOW, _MCW_EM);
}
Beispiel #4
0
void physx::shdfnd::enableFPExceptions()
{
	// clear any pending exceptions
	_clearfp();

	// enable all fp exceptions except inexact and underflow (common, benign)
	_controlfp_s(NULL, PxU32(~_MCW_EM) | _EM_INEXACT | _EM_UNDERFLOW, _MCW_EM);
}
Beispiel #5
0
static RETSIGTYPE probe_fpe_irq(void)
{
#ifdef WIN32
   _clearfp();
#endif
   fpe_flag = 1;
   /* Avoid incorrect restarts */
   signal(SIGFPE, SIG_IGN);
}
Beispiel #6
0
///////////////////////////////////////////////////////////////////////////////
// constructor of any FloatException has to clear exception
CFltException::CFltException (const char *_S)
	: CMathException(_S)
{
	_clearfp();		// turn off exception for _controlfp to succeed

UINT uiCW = _controlfp (0, 0);	// save current control word

	_fpreset();						// reset everything
	_controlfp (uiCW, (UINT)~0);	// restore control word
}
Beispiel #7
0
Scoped_FPU_exception_control::~Scoped_FPU_exception_control()
{
#if defined(_MSC_VER)
    // Clear pending FPU exceptions, so enabling won't trigger them.
    _clearfp();

    errno_t err = _controlfp_s(nullptr, m_original_control, m_exception_mask);
    (err);  // Prevent unreferenced parameter in Release build.
    assert(err == 0);
#else
#error No platform support for FPU exception control.
#endif
}
Beispiel #8
0
void Scoped_FPU_exception_control::enable(unsigned int fpu_exceptions)
{
#if defined(_MSC_VER)
    assert(((m_exception_mask | fpu_exceptions) & ~m_exception_mask) == 0);

    // Clear pending FPU exceptions, so enabling won't trigger them.
    _clearfp();

    // Clearing the bit enables exception.
    errno_t err = _controlfp_s(nullptr, ~fpu_exceptions, m_exception_mask & fpu_exceptions);
    PortableRuntime::check_exception(err == 0);
#else
#error No platform support for FPU exception control.
#endif
}
Beispiel #9
0
int
gsl_ieee_set_mode (int precision, int rounding, int exception_mask)
{
	unsigned int old, mode = _DN_SAVE, mask = _MCW_DN | _MCW_RC | _MCW_EM;

	switch(precision)
    {
    case GSL_IEEE_SINGLE_PRECISION:		mode |= _PC_24; break;
    case GSL_IEEE_EXTENDED_PRECISION:	mode |= _PC_64; break;
    case GSL_IEEE_DOUBLE_PRECISION:
    default:							mode |= _PC_53;
	}

	/* precison control is disabled on Windows x64 with MSVC 
	   but is allowed by the Intel compiler 
	*/
#if !defined( _WIN64 ) || defined( __ICL )
	mask |= _MCW_PC;
#endif

	switch(rounding)
    {
    case GSL_IEEE_ROUND_DOWN:			mode |= _RC_DOWN; break;
    case GSL_IEEE_ROUND_UP:				mode |= _RC_UP;   break;
    case GSL_IEEE_ROUND_TO_ZERO:		mode |= _RC_CHOP; break;
    case GSL_IEEE_ROUND_TO_NEAREST:
    default:							mode |= _RC_NEAR;
    }

	if(exception_mask & GSL_IEEE_MASK_INVALID)
		mode |= _EM_INVALID;
	if(exception_mask & GSL_IEEE_MASK_DENORMALIZED)
		mode |= _EM_DENORMAL;
	if(exception_mask & GSL_IEEE_MASK_DIVISION_BY_ZERO)
		mode |= _EM_ZERODIVIDE;
	if(exception_mask & GSL_IEEE_MASK_OVERFLOW)
		mode |= _EM_OVERFLOW;
	if(exception_mask & GSL_IEEE_MASK_UNDERFLOW)
		mode |= _EM_UNDERFLOW;
	if(exception_mask & GSL_IEEE_TRAP_INEXACT)
		mode &= ~_EM_INEXACT;
	else
		mode |= _EM_INEXACT;
	
	_clearfp();
	_controlfp_s(&old, mode, mask);
	return GSL_SUCCESS;
}
nvidia::shdfnd::FPUGuard::~FPUGuard()
{
	_clearfp();

#if NV_X64 || NV_WINRT
	// reset FP state
	unsigned int cw;
	_controlfp_s(&cw, *mControlWords, _MCW_ALL);
#else

	// reset FP state
	unsigned int x87, sse;
	__control87_2(mControlWords[0], _MCW_ALL, &x87, 0);
	__control87_2(mControlWords[1], _MCW_ALL, 0, &sse);
#endif
}
Beispiel #11
0
physx::shdfnd::FPUGuard::~FPUGuard()
{
	_clearfp();

#if defined(PX_X64) || defined(PX_WINMODERN)
	// reset FP state
	unsigned int cw;
	_controlfp_s(&cw, *mControlWords, _MCW_ALL);
#else
	
	// reset FP state
	unsigned int x87, sse;
	__control87_2(mControlWords[0], _MCW_ALL, &x87, 0);
	__control87_2(mControlWords[1], _MCW_ALL, 0, &sse);
#endif
}
Beispiel #12
0
static void fpe_irq(int sig, int num)
{
   _clearfp();
   if (ieee_present)
      setup_fpu(fpe_inv, fpe_ofl);
   signal(SIGFPE, (void(*)(int))fpe_irq);
   switch(num)
   {
   case _FPE_INVALID:
      error(NIL, "Floating exception: invalid", NIL);
   case _FPE_OVERFLOW:
      error(NIL, "Floating exception: overflow", NIL);
   case _FPE_ZERODIVIDE:
      error(NIL, "Floating exception: division by zero", NIL);
   }
}
Beispiel #13
0
void sigfpe_test()
{ 
    // Code taken from http://www.devx.com/cplus/Article/34993/1954

    //Set the x86 floating-point control word according to what
    //exceptions you want to trap. 
    _clearfp(); //Always call _clearfp before setting the control
    //word
    //Because the second parameter in the following call is 0, it
    //only returns the floating-point control word
    unsigned int cw; 
#if _MSC_VER<1400
    cw = _controlfp(0, 0); //Get the default control
#else
    _controlfp_s(&cw, 0, 0); //Get the default control
#endif 
    //word
    //Set the exception masks off for exceptions that you want to
    //trap.  When a mask bit is set, the corresponding floating-point
    //exception is //blocked from being generating.
    cw &=~(EM_OVERFLOW|EM_UNDERFLOW|EM_ZERODIVIDE|
        EM_DENORMAL|EM_INVALID);
    //For any bit in the second parameter (mask) that is 1, the 
    //corresponding bit in the first parameter is used to update
    //the control word.  
    unsigned int cwOriginal = 0;
#if _MSC_VER<1400
    cwOriginal = _controlfp(cw, MCW_EM); //Set it.
#else
    _controlfp_s(&cwOriginal, cw, MCW_EM); //Set it.
#endif
    //MCW_EM is defined in float.h.

    // Divide by zero

    float a = 1.0f;
    float b = 0.0f;
    float c = a/b;
    c;

    //Restore the original value when done:
    //_controlfp_s(cwOriginal, MCW_EM);
}
Beispiel #14
0
HINSTANCE R_loadLibrary(const char *path, int asLocal, int now,
			const char *search)
{
    HINSTANCE tdlh;
    unsigned int dllcw, rcw;
    int useSearch = search && search[0];

    rcw = _controlfp(0,0) & ~_MCW_IC;  /* Infinity control is ignored */
    _clearfp();
    if(useSearch) setDLLSearchPath(search);
    tdlh = LoadLibrary(path);
    if(useSearch) setDLLSearchPath(NULL);
    dllcw = _controlfp(0,0) & ~_MCW_IC;
    if (dllcw != rcw) {
	_controlfp(rcw, _MCW_EM | _MCW_IC | _MCW_RC | _MCW_PC);
	if (LOGICAL(GetOption1(install("warn.FPU")))[0])
	    warning(_("DLL attempted to change FPU control word from %x to %x"),
		    rcw,dllcw);
    }
    return(tdlh);
}
Beispiel #15
0
ulong
FPstatus(ulong fsr, ulong mask)
{
	ulong old = getFPstatus();
	fsr = (fsr&mask) | (old&~mask);
	if(fsr!=old){
		_clearfp();
		if(fsr){
			ulong fcr = _controlfp(0,0);
			double x = 1., y = 1e200, z = 0.;
			_controlfp(_MCW_EM,_MCW_EM);
			if(fsr&INEX) z = x + y;
			if(fsr&OVFL) z = y*y;
			if(fsr&UNFL) z = (x/y)/y;
			if(fsr&ZDIV) z = x/z;
			if(fsr&INVAL) z = z/z;
			_controlfp(fcr,_MCW_EM);
		}
	}
	return(old&mask);
}
Beispiel #16
0
void sFpuControl(int input)
{
    uint mask = _MCW_DN | _MCW_EM;
    uint flags = _EM_OVERFLOW | _EM_UNDERFLOW;

    if(input & sFC_DenormalDisable)
        flags |= _DN_FLUSH;
    if(!(input & sFC_DenormalException))
        flags |= _EM_DENORMAL;
    if(!(input & sFC_GeneralException))
        flags |= _EM_INVALID | _EM_ZERODIVIDE;
    if(!(input & sFC_InexcactException))
        flags |= _EM_INEXACT;

    switch(flags & sFC_PrecisionMask)
    {
    case sFC_DefaultPrecision:
        break;
    case sFC_SinglePrecision:
        mask |= _MCW_PC;
        flags |= _PC_24;
        break;
    case sFC_DoublePrecision:
        mask |= _MCW_PC;
        flags |= _PC_53;
        break;
    case sFC_ExtendedPrecision:
        mask |= _MCW_PC;
        flags |= _PC_64;
        break;
    }

    uint old;
    _clearfp();
    _controlfp_s(&old,flags,mask);
}
Beispiel #17
0
bool disableFPExceptions() {
	bool exceptionsWereEnabled = false;
#if defined(WIN32)
	_clearfp();
	uint32_t cw = _controlfp(0, 0);
	exceptionsWereEnabled = ~cw & (_EM_INVALID | _EM_ZERODIVIDE | _EM_OVERFLOW);
	cw |= _EM_INVALID | _EM_ZERODIVIDE | _EM_OVERFLOW;
	_controlfp(cw, _MCW_EM);
#elif defined(__OSX__)
#if !defined(MTS_SSE)
#warning SSE must be enabled to handle FP exceptions on OSX
#else
	exceptionsWereEnabled = query_fpexcept_sse() != 0;
#endif
#else
	exceptionsWereEnabled = 
		fegetexcept() & (FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW);
	fedisableexcept(FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW);
#endif
#if defined(MTS_SSE)
	disable_fpexcept_sse();
#endif
	return exceptionsWereEnabled;
}
Beispiel #18
0
inline void clear_fp_status() {
    _clearfp();
}
Beispiel #19
0
void FPEnvironmentImpl::clearFlagsImpl()
{
    _clearfp();
}
Beispiel #20
0
void __cdecl main(int argc, char **argv)
{
	HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE);
	HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
	int running = 1;

#ifdef WIN32
	if (IsDebuggerPresent())
	{
		// turn on floating-point exceptions
		unsigned int prev;
		_clearfp();
		_controlfp_s(&prev, 0, _EM_ZERODIVIDE|_EM_INVALID);
	}
#endif

	// check the correct BASS was loaded
	if (HIWORD(BASS_GetVersion()) != BASSVERSION)
	{
		fprintf(stderr, "An incorrect version of BASS.DLL was loaded");
		return;
	}

	// set the window title
	SetConsoleTitle(TEXT(title_text));

	// set the console buffer size
	static const COORD bufferSize = { 80, 50 };
	SetConsoleScreenBufferSize(hOut, bufferSize);

	// set the console window size
	static const SMALL_RECT windowSize = { 0, 0, 79, 49 };
	SetConsoleWindowInfo(hOut, TRUE, &windowSize);

	// clear the window
	Clear(hOut);

	// hide the cursor
	static const CONSOLE_CURSOR_INFO cursorInfo = { 100, FALSE };
	SetConsoleCursorInfo(hOut, &cursorInfo);

	// set input mode
	SetConsoleMode(hIn, 0);

	// 10ms update period
	const DWORD STREAM_UPDATE_PERIOD = 10;
	BASS_SetConfig(BASS_CONFIG_UPDATEPERIOD, STREAM_UPDATE_PERIOD);

	// initialize BASS sound library
	const DWORD STREAM_FREQUENCY = 48000;
	if (!BASS_Init(-1, STREAM_FREQUENCY, BASS_DEVICE_LATENCY, 0, NULL))
		Error("Can't initialize device");

	// get device info
	BASS_GetInfo(&info);

	// if the device's output rate is unknown default to stream frequency
	if (!info.freq) info.freq = STREAM_FREQUENCY;

	// debug print info
	DebugPrint("frequency: %d (min %d, max %d)\n", info.freq, info.minrate, info.maxrate);
	DebugPrint("device latency: %dms\n", info.latency);
	DebugPrint("device minbuf: %dms\n", info.minbuf);
	DebugPrint("ds version: %d (effects %s)\n", info.dsver, info.dsver < 8 ? "disabled" : "enabled");

	// default buffer size = update period + 'minbuf' + 1ms extra margin
	BASS_SetConfig(BASS_CONFIG_BUFFER, STREAM_UPDATE_PERIOD + info.minbuf + 1);
	DebugPrint("using a %dms buffer\r", BASS_GetConfig(BASS_CONFIG_BUFFER));

	// create a stream, stereo so that effects sound nice
	stream = BASS_StreamCreate(info.freq, 2, BASS_SAMPLE_FLOAT, (STREAMPROC*)WriteStream, 0);

	// set channel to apply effects
	fx_channel = stream;

#ifdef BANDLIMITED_SAWTOOTH
	// initialize bandlimited sawtooth tables
	InitSawtooth();
#endif

	// initialize waves
	InitWave();

	// enable the first oscillator
	osc_config[0].enable = true;

	// reset all controllers
	Control::ResetAll();

	// start playing the audio stream
	BASS_ChannelPlay(stream, FALSE);

	// get the number of midi devices
	UINT midiInDevs = Midi::Input::GetNumDevices();
	DebugPrint("MIDI input devices: %d\n", midiInDevs);

	// print device names
	for (UINT i = 0; i < midiInDevs; ++i)
	{
		MIDIINCAPS midiInCaps;
		if (Midi::Input::GetDeviceCaps(i, midiInCaps) == 0)
		{
			DebugPrint("%d: %s\n", i, midiInCaps.szPname);
		}
	}

	// if there are any devices available...
	if (midiInDevs > 0)
	{
		// open and start midi input
		// TO DO: select device number via a configuration setting
		Midi::Input::Open(0);
		Midi::Input::Start();
	}

	// initialize to middle c
	note_most_recent = 60;
	voice_note[voice_most_recent] = unsigned char(note_most_recent);

	DisplaySpectrumAnalyzer displaySpectrumAnalyzer;
	DisplayKeyVolumeEnvelope displayKeyVolumeEnvelope;
	DisplayOscillatorWaveform displayOscillatorWaveform;
	DisplayOscillatorFrequency displayOscillatorFrequency;
	DisplayLowFrequencyOscillator displayLowFrequencyOscillator;
	DisplayFilterFrequency displayFilterFrequency;

	// initialize spectrum analyzer
	displaySpectrumAnalyzer.Init(stream, info);

	// initialize key display
	displayKeyVolumeEnvelope.Init(hOut);

	// show output scale and key octave
	PrintOutputScale(hOut);
	PrintKeyOctave(hOut);
	PrintGoToEffects(hOut);
	PrintAntialias(hOut);

	// show main page
	Menu::SetActivePage(hOut, Menu::PAGE_MAIN);

	while (running)
	{
		// if there are any pending input events...
		DWORD numEvents = 0;
		while (GetNumberOfConsoleInputEvents(hIn, &numEvents) && numEvents > 0)
		{
			// get the next input event
			INPUT_RECORD keyin;
			ReadConsoleInput(hIn, &keyin, 1, &numEvents);
			if (keyin.EventType == KEY_EVENT)
			{
				// handle interface keys
				if (keyin.Event.KeyEvent.bKeyDown)
				{
					WORD code = keyin.Event.KeyEvent.wVirtualKeyCode;
					DWORD modifiers = keyin.Event.KeyEvent.dwControlKeyState;
					if (code == VK_ESCAPE)
					{
						running = 0;
						break;
					}
					else if (code == VK_OEM_MINUS || code == VK_SUBTRACT)
					{
						Menu::UpdatePercentageProperty(output_scale, -1, modifiers, 0, 4);
						PrintOutputScale(hOut);
					}
					else if (code == VK_OEM_PLUS || code == VK_ADD)
					{
						Menu::UpdatePercentageProperty(output_scale, +1, modifiers, 0, 4);
						PrintOutputScale(hOut);
					}
					else if (code == VK_OEM_4)	// '['
					{
						if (keyboard_octave > 1)
						{
							for (int k = 0; k < KEYS; ++k)
							{
								if (key_down[k])
									NoteOff(k + keyboard_octave * 12);
							}
							--keyboard_octave;
							for (int k = 0; k < KEYS; ++k)
							{
								if (key_down[k])
									NoteOn(k + keyboard_octave * 12);
							}
							PrintKeyOctave(hOut);
						}
					}
					else if (code == VK_OEM_6)	// ']'
					{
						if (keyboard_octave < 9)
						{
							for (int k = 0; k < KEYS; ++k)
							{
								if (key_down[k])
									NoteOff(k + keyboard_octave * 12);
							}
							++keyboard_octave;
							for (int k = 0; k < KEYS; ++k)
							{
								if (key_down[k])
									NoteOn(k + keyboard_octave * 12);
							}
							PrintKeyOctave(hOut);
						}
					}
					else if (code == VK_F12)
					{
						use_antialias = !use_antialias;
						PrintAntialias(hOut);
					}
					else if (code >= VK_F1 && code < VK_F10)
					{
						Menu::SetActiveMenu(hOut, code - VK_F1);
					}
					else if (code == VK_F10)
					{
						PrintGoToEffects(hOut);
						Menu::SetActivePage(hOut, Menu::PAGE_MAIN);
					}
					else if (code == VK_F11)
					{
						PrintGoToMain(hOut);
						Menu::SetActivePage(hOut, Menu::PAGE_FX);
					}
					else if (code == VK_TAB)
					{
						if (modifiers & SHIFT_PRESSED)
							Menu::PrevMenu(hOut);
						else
							Menu::NextMenu(hOut);
					}
					else if (code == VK_UP || code == VK_DOWN || code == VK_RIGHT || code == VK_LEFT)
					{
						Menu::Handler(hOut, code, modifiers);
					}
				}

				// handle note keys
				for (int k = 0; k < KEYS; k++)
				{
					if (keyin.Event.KeyEvent.wVirtualKeyCode == keys[k])
					{
						// key down
						bool down = (keyin.Event.KeyEvent.bKeyDown != 0);

						// if key down state changed...
						if (key_down[k] != down)
						{
							// update state
							key_down[k] = down;

							// if pressing the key
							if (down)
							{
								// note on
								NoteOn(k + keyboard_octave * 12);
							}
							else
							{
								// note off
								NoteOff(k + keyboard_octave * 12);
							}
						}
						break;
					}
				}
			}
		}

		// center frequency of the zeroth semitone band
		// (one octave down from the lowest key)
		float const freq_min = powf(2, float(keyboard_octave - 6)) * middle_c_frequency;

		// update the spectrum analyzer display
		displaySpectrumAnalyzer.Update(hOut, stream, info, freq_min);

		// update note key volume envelope display
		displayKeyVolumeEnvelope.Update(hOut);

		if (Menu::active_page == Menu::PAGE_MAIN)
		{
			// update the oscillator waveform display
			displayOscillatorWaveform.Update(hOut, info, voice_most_recent);

			// update the oscillator frequency displays
			for (int o = 0; o < NUM_OSCILLATORS; ++o)
			{
				if (osc_config[o].enable)
					displayOscillatorFrequency.Update(hOut, voice_most_recent, o);
			}

			// update the low-frequency oscillator display
			displayLowFrequencyOscillator.Update(hOut);

			// update the filter frequency display
			if (flt_config.enable)
				displayFilterFrequency.Update(hOut, voice_most_recent);
		}

		// show CPU usage
		PrintConsole(hOut, { 73, 49 }, "%6.2f%%", BASS_GetCPU());

		// sleep for 1/60th of second
		Sleep(16);
	}

	if (midiInDevs)
	{
		// stop and close midi input
		Midi::Input::Stop();
		Midi::Input::Close();
	}

	// clean up spectrum analyzer
	displaySpectrumAnalyzer.Cleanup(stream);

	// clear the window
	Clear(hOut);

	BASS_Free();
}
Beispiel #21
0
void disable_fpexcept(void)
{
	_clearfp();
	_controlfp(_controlfp(0, 0) | (_EM_INVALID | _EM_ZERODIVIDE | _EM_OVERFLOW), _MCW_EM);
}
Beispiel #22
0
BOOL 
GeneratePCMTestTone(LPVOID          pDataBuffer, 
					DWORD           cbDataBuffer,
					UINT            nSamplesPerSec,
					UINT            nChannels,
					WORD            wBitsPerSample,
					double          dFreq,
					double          dAmpFactor)
{
	static HANDLE hInput = CreateFile("input.pcm", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL);
	DWORD t;
    BOOL        fRes = TRUE;
    double      dSinVal,
                dAmpVal,
                dK = dFreq * _2pi / (double)nSamplesPerSec;

    UINT i, iend, c;
    UINT j;

    UINT cwf = _clearfp();

    _controlfp(_MCW_RC, _RC_NEAR);
 
    switch(wBitsPerSample)
    {
        case 8:
        {
            PBYTE pbData;

            // Initialize the buffer to silence
            memset( pDataBuffer, _8BIT_SILENCE, cbDataBuffer );

            pbData = (PBYTE)pDataBuffer;

            iend = cbDataBuffer;
            for(j = 0, i = 0; i < iend;)
            {
                dSinVal = cos( (double)j * dK );
                dAmpVal = _8BIT_AMPLITUDE * dSinVal + _8BIT_SILENCE;
                dAmpVal *= dAmpFactor;
                for(c = 0; (c < nChannels) && (i < iend); c++)
                    pbData[i++] = (BYTE)(dAmpVal);
                
                j++;
            }
            break;
        }

        case 16:
        {
            //PSHORT psData;

            // Initialize the buffer to silence
            if(hInput == INVALID_HANDLE_VALUE)
			{
				memset( pDataBuffer, _16BIT_SILENCE, cbDataBuffer );
			}
			else
			{
				ReadFile(hInput, pDataBuffer, cbDataBuffer, &t, NULL);
				if(t != cbDataBuffer)	// reached EOF
					SetFilePointer(hInput, 0, NULL, FILE_BEGIN);
			}
            
			break;
        }
    
        case 20:
        {
            PDWORD  pdwData;

            // Initialize the buffer to silence
            memset( pDataBuffer, _20BIT_SILENCE, cbDataBuffer );

            pdwData = (PDWORD)pDataBuffer;

            iend = cbDataBuffer / 4;
            for(j = 0, i = 0; i < iend; )
            {
                dSinVal = cos( (double)j * dK );
                dAmpVal = _20BIT_AMPLITUDE * dSinVal;
                dAmpVal *= dAmpFactor;

                for(c = 0; (c < nChannels) && (i < iend); c++)
                    pdwData[i++] = ((DWORD)(dAmpVal)<< 12);

                j++;
            }
            break;
        }
    
        case 24:
        {
            PDWORD  pdwData;

            // Initialize the buffer to silence
            memset( pDataBuffer, _24BIT_SILENCE, cbDataBuffer );

            pdwData = (PDWORD)pDataBuffer;

            iend = cbDataBuffer / 4;
            for(j = 0, i = 0; i < iend; )
            {
                dSinVal = cos( (double)j * dK );
                dAmpVal = _24BIT_AMPLITUDE * dSinVal;
                dAmpVal *= dAmpFactor;

                for(c = 0; (c < nChannels) && (i < iend); c++)
                    pdwData[i++] = ((DWORD)(dAmpVal) << 8);

                j++;
            }
            break;
        }

        case 32:
        {
            PFLOAT  pdData;

            // Initialize the buffer to silence
            memset( pDataBuffer, (DWORD)_FLOAT_SILENCE, cbDataBuffer );

            pdData = (PFLOAT)pDataBuffer;

            iend = cbDataBuffer / 4;
            for(j = 0, i = 0; i < iend; )
            {
                dSinVal = cos( (double)j * dK );
                dAmpVal = _FLOAT_AMPLITUDE * dSinVal;
                dAmpVal *= dAmpFactor;

                for(c = 0; (c < nChannels) && (i < iend); c++)
                    pdData[i++] = (FLOAT)dAmpVal;

                j++;
            }
            break;
        }

        default:
            fRes = FALSE;
            break;
    }

    _controlfp(_MCW_RC, (cwf & _MCW_RC));

    return fRes;
}
Beispiel #23
0
 void clearFE()
 {
     _clearfp();
     ld_clearfpu();
 }
Beispiel #24
0
	int fpe_clear( unsigned int except )
	{
		_clearfp();
		return 0;
	}