Пример #1
0
bool CGmResMan::MakeWav_( TWav *poWav, const char *pcFileName )
{
	poWav->Clear();
	
	CStr oFileName( CGmResMan::DATA_DIR + "audio/" + pcFileName );
	const int iDot = oFileName.FindRev( oFileName.GetSize() - 1, '.' );
	if( iDot < 0 )
		return false;
	CStr oExt( oFileName.GetData() + iDot + 1 );
	oExt.ToLower();
	
	if( oExt == "wav" )
	{
		CFileStreamWav oWavFile;
		if( oWavFile.Open( oFileName, CFile::FLAG_READ ) )
		{
			if( oWavFile.m_uiSampleFreq == AUDIO_SAMPLE_FREQ
			 || oWavFile.m_uiChannels == 2
			 || oWavFile.m_uiDataBytes != 0 )
			{
				unsigned char *pucBuffer = new unsigned char[ oWavFile.m_uiDataBytes ];
				if( !oWavFile.Read( pucBuffer, oWavFile.m_uiDataBytes ) )
				{
					ERR( "WAV File %s\n", pcFileName );
				}
				else
				{
					const unsigned int uiValueCount = oWavFile.m_uiDataBytes / sizeof(CAS::TValue);
					const unsigned int uiSampleCount = uiValueCount / 2;
					poWav->Init( uiSampleCount );
					CAS::TValue *ptValues = (CAS::TValue *)pucBuffer;
					for( unsigned int i=0; i<uiSampleCount; ++i )
					{
						const double dL( ( *ptValues ) * ( 1.0 / AUDIO_VALUE_MAX ) );
						++ptValues;
						//const double dR( ( *ptValues ) * ( 1.0 / AUDIO_VALUE_MAX ) );
						++ptValues;
						poWav->Write( i, dL ); //, dR );
					}
				}
				DELETE_ARRAY( pucBuffer );
				oWavFile.Close();
			}
		}
	}
#ifdef GM_USE_OGG
	else if( oExt == "ogg" )
	{
		LoadOGG_( oFileName, poWav );
	}
#endif // GM_USE_OGG
	else
	{
		ERR( "Unsupported filename extension: %s\n", pcFileName );
		return false;
	}
	
	LOG( "%s loaded.\n", pcFileName );
	return true;
}
Пример #2
0
bool CGmObjSkybox::Load( const char *pcSubDir, const char *pcFileNamePrefix, const char *pcFileNamePostfix )
{
    Clear();

    static const char * apcOrient_[] = {
        "_left", "_right", "_bottom", "_top", "_back", "_front"
    };
    static const unsigned int auiIdx_[] = {
        TEX_SKY_LEFT, TEX_SKY_RIGHT,
        TEX_SKY_BOTTOM, TEX_SKY_TOP,
        TEX_SKY_BACK, TEX_SKY_FRONT,
    };

    // ugly but...
    CStr oSubDir( pcSubDir );
    unsigned int uiSubDirLen( oSubDir.GetSize() );
    if( uiSubDirLen && oSubDir[uiSubDirLen-1] != '/' )
    {
        ++uiSubDirLen;
        oSubDir += '/';
    }
    CStr oFileNamePrefix;
    if( !pcFileNamePrefix || !strlen( pcFileNamePrefix ) )
    {
        unsigned int i( uiSubDirLen - 1 );
        while( i )
        {
            --i;
            const char c( oSubDir[i] );
            if( c == '/' )
                break;
        }
        oFileNamePrefix = oSubDir.GetSub( i, uiSubDirLen - 1 );
    }
    else
    {
        oFileNamePrefix = pcFileNamePrefix;
    }

    unsigned int i = 6;
    while( i )
    {
        --i;
        const char *pcOrient( apcOrient_[i] );
        const unsigned int uiIdx( auiIdx_[i] );
        CStr oFileName( oSubDir );
        oFileName += oFileNamePrefix;
        oFileName += pcOrient;
        oFileName += pcFileNamePostfix;
        CGTex2 * poTex( m_poResMan_->NewTexture( oFileName, true, true ) );
        if( !poTex )
            return false;
        m_apoTex[uiIdx] = poTex;
    }

    Init();
    return true;
}
Пример #3
0
void* MediaCommandImportMedia::ExecuteE(void* p_upFileName, void* p_upArray, void*)
{
	//;//cout_commented_out_4_release << "MediaCommandImportMedia" << endl;
	string oFileName(static_cast<const char*>(p_upFileName));
	int32* vpArray = static_cast<int32*>(p_upArray);

	EMMediaEngine* opEngine = EMMediaEngine::Instance();
	if(opEngine -> GetMediaProject() -> GetMediaPool() == NULL)
		EMDebugger("ERROR! Media pool is NULL!");
	try
	{
		EMMediaPool* opPool = opEngine -> GetMediaProject() -> GetMediaPool();
		opPool -> AddMediaFileE(oFileName, vpArray);
		EMMediaEngine::Instance() -> GetMediaProject() -> SetDirty(true);
	}
	catch(EMException* e)
	{
		EMExceptionHandler::Instance() -> HandleException(*e);
	}
	return NULL;
}
Пример #4
0
bool CGmResMan::MakeTex_( CGTex2 *poTex, const char *pcFileName, bool bSmooth, bool bClamp )
{
	if( !poTex )
		return false;
	
	CStr oFileName( CGmResMan::DATA_DIR + pcFileName );
	const int iDot = oFileName.FindRev( oFileName.GetSize() - 1, '.' );
	if( iDot < 0 )
		return false;
	CStr oExt( oFileName.GetData() + iDot + 1 );
	oExt.ToLower();
	
	static const GLenum aeFormat_[] = { GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA };
	poTex->m_eType = GL_UNSIGNED_BYTE;
	poTex->SetSmooth( bSmooth );
	//poTex->m_iMinFilter = ( bSmooth ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST );
	//poTex->m_iMagFilter = ( bSmooth ? GL_LINEAR : GL_NEAREST );
	if( bClamp )
		poTex->m_iWrapS = poTex->m_iWrapT = GL_CLAMP_TO_EDGE;
	else
		poTex->m_iWrapS = poTex->m_iWrapT = GL_REPEAT;
	
	CFileBlockImg *poFile = 0;
	if( oExt == "bmp" )
	{
		poFile = new CFileBlockImgBmp;
	}
#ifdef GM_USE_PNG
	else if( oExt == "png" )
	{
		poFile = new CFileBlockImgPng;
	}
#endif // GM_USE_PNG
#ifdef GM_USE_JPEG
	else if( oExt == "jpg" || oExt == "jpeg" )
	{
		poFile = new CFileBlockImgJpg;
	}
#endif // GM_USE_JPEG

	if( poFile )
	{
		if( !poFile->Load( oFileName.GetData() ) )
		{
			ERR( "Texture %s.\n", oFileName.GetData() );
			DELETE_INSTANCE( poFile );
			return false;
		}
		poTex->m_iChannels = poFile->m_uiChannels;
		poTex->m_eFormat = aeFormat_[poTex->m_iChannels - 1];
		poTex->m_iWidth = poFile->m_uiWidth;
		poTex->m_iHeight = poFile->m_uiHeight;
		poTex->InitCopyData();
		poFile->Decode( poTex->m_pvData, poTex->m_iWidth * poTex->m_iHeight * poTex->m_iChannels );
		poFile->Close();
		DELETE_INSTANCE( poFile );
	}
	else
	{
		ERR( "Unsupported filename extension: %s.\n", pcFileName );
		return false;
	}
	
	LOG( "%s loaded.\n", pcFileName );
	return true;
}
Пример #5
0
CABuffer * CGmResMan::NewABuffer( const char *pcFileName )
{
	CABuffer * poABuffer = (CABuffer *)FindFileEntry( pcFileName );
	if( !poABuffer )
	{
		CStr oFileName( CGmResMan::DATA_DIR + "audio/" + pcFileName );
		const int iDot = oFileName.FindRev( oFileName.GetSize() - 1, '.' );
		if( iDot < 0 )
			return false;
		CStr oExt( oFileName.GetData() + iDot + 1 );
		oExt.ToLower();

		bool bLoadOk = false;
		
		LOG( "Loading %s.\n", oFileName.GetData() );
		
		poABuffer = new CABuffer;
		poABuffer->Init();
		
		if( oExt == "wav" )
		{
			CFileStreamWav oWav;
			if( oWav.Open( oFileName, CFile::FLAG_READ ) )
			{
				unsigned char * pcBuffer = new unsigned char[oWav.m_uiDataBytes];
				if( pcBuffer )
				{
					oWav.Read( pcBuffer, oWav.m_uiDataBytes );
					
					//ASSERT( oWav.m_uiChannels == 1 );
					
					if( poABuffer->Load( pcBuffer, oWav.m_uiDataBytes, oWav.m_uiChannels, oWav.m_uiSampleFreq ) )
					{
						bLoadOk = true;
					}
					else
					{
						ERR( "Audio Buffer %s.\n", pcFileName );
						DELETE_INSTANCE( poABuffer );
					}
					DELETE_ARRAY( pcBuffer );
				}
			}
			else
			{
				bLoadOk = false;
			}
		}
#ifdef GM_USE_OGG
		else if( oExt == "ogg" )
		{
			unsigned char *pucData = 0;
			unsigned int uiBytes = 0;
			unsigned int uiChannelCount = 0;
			unsigned int uiSampleFreq = 0;
			if( bLoadOk = LoadOGG_( oFileName, &pucData, &uiBytes, &uiChannelCount, &uiSampleFreq ) )
			{
				poABuffer->Load( pucData, uiBytes, uiChannelCount, uiSampleFreq );
				DELETE_ARRAY( pucData );
			}
		}
#endif // GM_USE_OGG
		else
		{
			ERR( "Audio File %s.\n", oFileName.GetData() );
			bLoadOk = false;
		}
		
		if( poABuffer && bLoadOk )
		{
			m_oArrABuffer.Append( poABuffer );
			NewFileEntry( pcFileName, poABuffer );
		}
		else
		{
			DELETE_INSTANCE( poABuffer );
		}
	}
	else
	{
		LOG( "Audio file skipped: %s.\n", pcFileName );
	}
	return poABuffer;
}
Пример #6
0
void ITSSDDQAMaker(char *iFile, Int_t MaxEvts=1000000, Int_t FirstEvt=0) {

  //To have Baseline Histos uncomment parts with " // BL!!! " comment

cout << "SDD Quality Assurance Prototype Macro" << endl; 

const Int_t nSDDmodules= 260;
const Int_t imodoffset = 240;
const Int_t modtotSDD  = nSDDmodules*2;
const Int_t anode = 256;

Float_t xi = -0.5;
Float_t xf = xi + nSDDmodules;
TH1F *hModulePattern = new TH1F("hModulePattern","Modules pattern",nSDDmodules,xi,xf);
xf = xi + modtotSDD;
TH1F *hModuleSidePattern = new TH1F("hModuleSidePattern","Modules/Side pattern",modtotSDD,xi,xf);

TH2F *hModuleChargeMap[modtotSDD];  //260 dx e 260 sx  with A, T, Q
TH2F *hModuleCountsMap[modtotSDD];  //260 dx e 260 sx  with A, T, Ncounts
TH2I *hModuleCarlos = new TH2I("hModuleCarlos","hModuleCarlos",modtotSDD,xi,xf,101,-0.5,100.5);
/*
  TH1F *hModuleSideBL[modtotSDD][anode];                                // BL!!!
*/ 


//-------histograms definition 
Char_t *hisnam = new Char_t[50];
Char_t *histit = new Char_t[50];  
Char_t *hisnam2 = new Char_t[50];
Char_t *histit2 = new Char_t[50];    
Char_t *hisnam3 = new Char_t[50];
 for(Int_t imod=0; imod<nSDDmodules;imod++){
   for(Int_t isid=0;isid<2;isid++){
     Int_t index=2*imod+isid;       //260*2 position

     sprintf(hisnam,"chargeMap%d",index);
     sprintf(histit,"Total Charge, module number %d",index);
     hModuleChargeMap[index]=new TH2F(hisnam,histit,256,-0.5,255.5,256,-0.5,255.5);  

     sprintf(hisnam2,"countsMap%d",index);
     sprintf(histit2,"Number of Counts, module number %d",index);
     hModuleCountsMap[index] = new TH2F(hisnam2,histit2,256,-0.5,255.5,256,-0.5,255.5);
     /*
       for(Int_t ianode=0; ianode<anode; ianode++){                         // BL!!!
       sprintf(hisnam3,"BL_module_%d_%d",index,ianode); 
       //cout<<hisnam3 <<endl;
       hModuleSideBL[index][ianode] = new TH1F(hisnam3,hisnam3,256,0.,1024.);
     }
     */
   }
 }

  TString strFile = iFile;
  strFile += "?EventType=7";
  AliRawReader *rd = new AliRawReaderDate(strFile.Data(),FirstEvt);  // open run
  Int_t evCounter = 0;
  do{                       // start loop on events
    if(++evCounter > MaxEvts) { cout << MaxEvts << " events read, stop" << endl; evCounter--; break; }  
    cout << "Read Event: " << evCounter+FirstEvt-1 << endl;

    rd->RequireHeader(kFALSE);             
    rd->Reset();                           // reset the current position to the beginning of the event
 
    Int_t nSkip = 0;                     // number of skipped signals
    AliITSRawStreamSDD s(rd);            //This class provides access to ITS SDD digits in raw data.
    Int_t iddl;
    Int_t isddmod;
    Int_t moduleSDD;
    gStyle->SetPalette(1);
    while(s.Next()){                     //read the next raw digit; returns kFALSE if there is no digit left
      if(s.IsCompletedModule()) continue;
      if(s.IsCompletedDDL()) continue;
      iddl=rd->GetDDLID()-2; // -2 is temporary for test raw data

	isddmod=s.GetModuleNumber(iddl,s.GetCarlosId());        //this is the FEE Carlos
       	//cout<<"DDLID= "<<iddl <<"; Module number= " <<isddmod  <<endl;
	if(isddmod >= imodoffset) { 
	  hModulePattern->Fill(isddmod-imodoffset);             // 0 to 259    so  240 to 499
	  moduleSDD=2*(isddmod-imodoffset)+s.GetChannel();
          hModuleSidePattern->Fill(moduleSDD);                  // 0 to 519
	  hModuleCarlos->Fill(isddmod-imodoffset,s.GetCarlosId());
          //cout << "anode " << s.GetCoord1() << ", time bin: " << s.GetCoord2() << ", charge: " << s.GetSignal() << endl;	  
	  Int_t coord1 = s.GetCoord1();
 	  Int_t coord2 = s.GetCoord2();
 	  Int_t signal = s.GetSignal();
	  hModuleChargeMap[moduleSDD]->Fill(coord2, coord1,signal);
          hModuleCountsMap[moduleSDD]->Fill(coord2, coord1 );   
	  //hModuleSideBL[moduleSDD][coord1]->Fill(signal);             // BL  !!!
	} else {
	  nSkip++;
	}
    }    
    cout << "End of Event " << evCounter+FirstEvt-1 << ", " << nSkip << " wrong module numbers" << endl;
  } while(rd->NextEvent()); // end loop on events
  delete rd;

  cout << "end after " << evCounter << " events" << endl;
  /*
  TNtuple *Baseline = new TNtuple("Baseline","Baseline","HalfModule:Anode:Mean:RMS");      // BL!!!
  Float_t meanBL;
  Float_t rmsBL;  
  */
  for(Int_t i=0; i<modtotSDD; i++){   
    if(hModuleSidePattern->GetBinContent(i+1)){              //check if they're not empty
      hModuleChargeMap[i]->GetXaxis()->SetTitle("Time Bin");
      hModuleChargeMap[i]->GetYaxis()->SetTitle("Anode"); 
      hModuleCountsMap[i]->GetXaxis()->SetTitle("Time Bin");
      hModuleCountsMap[i]->GetYaxis()->SetTitle("Anode");  
      /*
      for(Int_t ianode=0; ianode<anode; ianode++ ){                                      // BL!!!
	hModuleSideBL[i][ianode]->GetXaxis()->SetTitle("ADC counts");
	hModuleSideBL[i][ianode]->GetYaxis()->SetTitle("#"); 
	meanBL = hModuleSideBL[i][ianode]->GetMean();
	rmsBL = hModuleSideBL[i][ianode]->GetRMS();
	gaussfitBL = hModuleSideBL[i][ianode]->Fit("gaus");	
	Baseline->Fill(i,ianode,meanBL,rmsBL);
      }
      */
    }
  }  
  
  hModuleSidePattern->GetXaxis()->SetTitle("2*(Module Number-1)+Side");
  hModuleSidePattern->GetYaxis()->SetTitle("Counts");  
  hModulePattern->GetXaxis()->SetTitle("Module Number");  
  hModulePattern->GetYaxis()->SetTitle("Counts");  


  //-------store Histograms
  cout << "Store Histograms" << endl;
  TString oFileName(iFile);
  oFileName.Append(".root");
  TFile *oFile = TFile::Open(oFileName,"recreate");
  hModulePattern->Write();
  hModuleSidePattern->Write();
  hModuleCarlos->Write();
  for(Int_t i=0; i<modtotSDD; i++){ 
      if(hModuleSidePattern->GetBinContent(i+1)){            //check if they're not empty
	hModuleChargeMap[i]->Write();
	hModuleCountsMap[i]->Write();     
	/* 
	for(Int_t ianode=0; ianode<anode; ianode++ ){                           // BL!!!
 	  hModuleSideBL[i][ianode]->Write();
	  Baseline->Write();
 	}
	*/
      }
  }
  
  oFile->Close();
  cout << "Clear memory" << endl;
  for(Int_t imod=0; imod<nSDDmodules;imod++){
    for(Int_t isid=0;isid<2;isid++){
      Int_t index=2*imod+isid;       //260*2 position
      delete hModuleChargeMap[index];
      delete hModuleCountsMap[index];       
      /*
      for(Int_t ianode=0; ianode<anode; ianode++ ){                              // BL!!!
	delete hModuleSideBL[index][ianode]; 
	delete Baseline;
      }
      */
    }
  }
  delete hModulePattern;
  delete hModuleSidePattern;
  delete hModuleCarlos;

}
Пример #7
0
bool ExportMediaDialog::InvalidCharExist(const char* p_vpPath, const char* p_vpFileName)
{
	string oPath(p_vpPath);
	string oFileName(p_vpFileName);
	bool vPathInvalidCharExist(false);
	bool vFileNameInvalidCharExist(false);
	int vPos(0);

	while(vPos < oPath.length() && vPos != -1)
	{
		vPos = oPath.find_first_of('\\', vPos);
		if(vPos == 0)
		{
			vPos++;
			continue;
		}
		if(vPos == 1)
		{
			vPos++;
			continue;
		}
		if(oPath[vPos + 1] == '\\' && vPos != -1)
		{
			vPathInvalidCharExist = true;
			break;
		}
		if(vPos != -1)
			vPos++;
	}
	if(oPath.find_first_of('.') == 0)
		vPathInvalidCharExist = true;
	if(oPath.find_first_of('/') != -1)
		vPathInvalidCharExist = true;
	if(oPath.find_first_of(':') != -1 && oPath.find_first_of(':') != 1)
		vPathInvalidCharExist = true;
	if(oPath.find_first_of('*') != -1)
		vPathInvalidCharExist = true;
	if(oPath.find_first_of('?') != -1)
		vPathInvalidCharExist = true;
	if(oPath.find_first_of('"') != -1)
		vPathInvalidCharExist = true;
	if(oPath.find_first_of('<') != -1)
		vPathInvalidCharExist = true;
	if(oPath.find_first_of('>') != -1)
		vPathInvalidCharExist = true;
	if(oPath.find_first_of('|') != -1)
		vPathInvalidCharExist = true;

	if(vPathInvalidCharExist)
		m_opMsgBox -> DisplayDialog(m_opDialogWindow -> GetNativeView(), "The specified path has invalid character(s)", "Invalid character(s)", EM_DIALOG_ICON_ERROR);

	if(oFileName.find_first_of('.') == 0)
		vFileNameInvalidCharExist = true;
	if(oFileName.find_first_of('\\') != -1)
		vFileNameInvalidCharExist = true;
	if(oFileName.find_first_of('/') != -1)
		vFileNameInvalidCharExist = true;
	if(oFileName.find_first_of(':') != -1)
		vFileNameInvalidCharExist = true;
	if(oFileName.find_first_of('*') != -1)
		vFileNameInvalidCharExist = true;
	if(oFileName.find_first_of('?') != -1)
		vFileNameInvalidCharExist = true;
	if(oFileName.find_first_of('"') != -1)
		vFileNameInvalidCharExist = true;
	if(oFileName.find_first_of('<') != -1)
		vFileNameInvalidCharExist = true;
	if(oFileName.find_first_of('>') != -1)
		vFileNameInvalidCharExist = true;
	if(oFileName.find_first_of('|') != -1)
		vFileNameInvalidCharExist = true;

	if(vFileNameInvalidCharExist)
		m_opMsgBox -> DisplayDialog(m_opDialogWindow -> GetNativeView(), "The File Name has invalid character(s)", "Invalid character(s)", EM_DIALOG_ICON_ERROR);

	if(vPathInvalidCharExist || vFileNameInvalidCharExist)
		return true;
	return false;
}