Exemple #1
0
/**
 * @function OpenWav
 * @brief open a wav file & start playback
 * @param const char *path: file path
 * @return int8_t: -1 -> error; 0 -> ok, the file is being played
 */
int8_t OpenWav(const char *path) {

  int8_t res = -1;

  WavStop();

  /*open the file*/
  if(f_open(&pFile, "waveform.wav", FA_OPEN_EXISTING | FA_READ) == FR_OK) {

    /*TODO: check & get wav file information*/
    /*WAV files are assumed to be 16bits 1CH 44.1kHz on this project*/
    //wav_get_file_info()...

    /*load file into buffers 1 & 2*/
    isBuffer1Empty = true;
    isBuffer2Empty = true;
    LoadBuffers();

    /*configure the playback frequency & its associated callback*/
    TmrSetFrequency(WAV_TIMER, 44100);
    TmrSetCallback(WAV_TIMER, Callback_1CH_16BITS);

    /*we always start playback by using BUFFER_1*/
    bufferToUse = BUFFER_1;

    /*start playback*/
    //WavPlay();

    res = 0;
  }

  return res;
}
Exemple #2
0
/**
 * @function WavProcess
 * @brief WAV player task; shall be called cyclically
 * @param none
 * @return none
 */
void WavProcess(void) {

  switch(state) {

    /*WAV_STOPPED / WAV_PAUSED -> nothing to do*/
    case WAV_STOPPED:
    case WAV_PAUSED:
      break;

    /*WAV_PLAYING: check if the buffers are not empty / if the music is finished*/
    case WAV_PLAYING:
      if(LoadBuffers() < 0) {
        WavStop();
      }
      break;

    default:
      WavStop();
      break;
  }
}
Exemple #3
0
void CRender::level_Load(IReader* fs)
{
	R_ASSERT						(0!=g_pGameLevel);
	R_ASSERT						(!b_loaded);

	// Begin
	pApp->LoadBegin					();
	dxRenderDeviceRender::Instance().Resources->DeferredLoad	(TRUE);
	IReader*						chunk;

	// Shaders
//	g_pGamePersistent->LoadTitle		("st_loading_shaders");
	g_pGamePersistent->LoadTitle		();
	{
		chunk = fs->open_chunk		(fsL_SHADERS);
		R_ASSERT2					(chunk,"Level doesn't builded correctly.");
		u32 count = chunk->r_u32	();
		Shaders.resize				(count);
		for(u32 i=0; i<count; i++)	// skip first shader as "reserved" one
		{
			string512				n_sh,n_tlist;
			LPCSTR			n		= LPCSTR(chunk->pointer());
			chunk->skip_stringZ		();
			if (0==n[0])			continue;
			xr_strcpy					(n_sh,n);
			LPSTR			delim	= strchr(n_sh,'/');
			*delim					= 0;
			xr_strcpy					(n_tlist,delim+1);
			Shaders[i]				= dxRenderDeviceRender::Instance().Resources->Create(n_sh,n_tlist);
		}
		chunk->close();
	}

	// Components
	Wallmarks					= xr_new<CWallmarksEngine>	();
	Details						= xr_new<CDetailManager>	();

	if	(!g_dedicated_server)	{
		// VB,IB,SWI
//		g_pGamePersistent->LoadTitle("st_loading_geometry");
		g_pGamePersistent->LoadTitle();
		{
			CStreamReader			*geom = FS.rs_open("$level$","level.geom");
			R_ASSERT2				(geom, "level.geom");
			LoadBuffers				(geom,FALSE);
			LoadSWIs				(geom);
			FS.r_close				(geom);
		}

		//...and alternate/fast geometry
		{
			CStreamReader			*geom = FS.rs_open("$level$","level.geomx");
			R_ASSERT2				(geom, "level.geomX");
			LoadBuffers				(geom,TRUE);
			FS.r_close				(geom);
		}

		// Visuals
//		g_pGamePersistent->LoadTitle("st_loading_spatial_db");
		g_pGamePersistent->LoadTitle();
		chunk						= fs->open_chunk(fsL_VISUALS);
		LoadVisuals					(chunk);
		chunk->close				();

		// Details
//		g_pGamePersistent->LoadTitle("st_loading_details");
		g_pGamePersistent->LoadTitle();
		Details->Load				();
	}

	// Sectors
//	g_pGamePersistent->LoadTitle("st_loading_sectors_portals");
	g_pGamePersistent->LoadTitle();
	LoadSectors					(fs);

	// 3D Fluid
	Load3DFluid					();

	// HOM
	HOM.Load					();

	// Lights
	// pApp->LoadTitle			("Loading lights...");
	LoadLights					(fs);

	// End
	pApp->LoadEnd				();

	// sanity-clear
	lstLODs.clear				();
	lstLODgroups.clear			();
	mapLOD.clear				();

	// signal loaded
	b_loaded					= TRUE	;
}
bool GLFramework::LoadModel(Geometry & geometry)
{
	LoadBuffers(geometry);
	return true;
}
HRESULT Kinect2Manager::InitializeDefaultSensorSeparateReaders()
{
#ifdef _USE_KINECT
    HRESULT hr;

    hr = GetDefaultKinectSensor(&m_pKinectSensor);
    if (FAILED(hr))
    {
        return hr;
    }

    if (m_pKinectSensor)
    {
        // Initialize the Kinect and get coordinate mapper and the body reader
        IBodyFrameSource* pBodyFrameSource = NULL;

        hr = m_pKinectSensor->Open();

        if (SUCCEEDED(hr))
        {
            hr = m_pKinectSensor->get_CoordinateMapper(&m_pCoordinateMapper);
        }

        if (SUCCEEDED(hr))
        {
            hr = m_pKinectSensor->get_BodyFrameSource(&pBodyFrameSource);
        }

        if (SUCCEEDED(hr))
        {
            hr = pBodyFrameSource->OpenReader(&m_pBodyFrameReader);
        }

        SafeRelease(pBodyFrameSource);


        // get the color reader
        IColorFrameSource* pColorFrameSource = NULL;

        if (SUCCEEDED(hr))
        {

            hr = m_pKinectSensor->get_ColorFrameSource(&pColorFrameSource);
        }

        if (SUCCEEDED(hr))
        {
            hr = pColorFrameSource->OpenReader(&m_pColorFrameReader);
        }

        SafeRelease(pColorFrameSource);


        // get the depth reader

        IDepthFrameSource* pDepthFrameSource = NULL;

        if (SUCCEEDED(hr))
        {
            hr = m_pKinectSensor->get_DepthFrameSource(&pDepthFrameSource);
        }

        if (SUCCEEDED(hr))
        {
            hr = pDepthFrameSource->OpenReader(&m_pDepthFrameReader);
        }

        SafeRelease(pDepthFrameSource);

        //get the body frame index reader

        IBodyIndexFrameSource * pBodyIndexFrameSource = NULL;

        if (SUCCEEDED(hr)) {
            hr = m_pKinectSensor->get_BodyIndexFrameSource(&pBodyIndexFrameSource);
        }

        if (SUCCEEDED(hr)) {
            hr = pBodyIndexFrameSource->OpenReader(&m_pBodyIndexFrameReader);
        }

        SafeRelease(pBodyIndexFrameSource);

    }

    if (!m_pKinectSensor || FAILED(hr))
    {
        std::cout << "no ready Kinect found!";
        return E_FAIL;
    }

    return hr;
#else
    LoadBuffers();
    return 0;
#endif
}