コード例 #1
0
ファイル: correction.c プロジェクト: KaiwenZ/CurveFitting
/******************************************************************************
 Program to test the correction module.  Reads in input params from the user
 and calucate the root using the methods in rootfinding module.
 int main(int argv, char* argv[])
 Where:
 int argv        - The number of command line parameters
 char *argv[]    - An array of pointers to the parameters
 returns: in     - 0 for success, non-zero for error
 errors:         - Error message printed to stderr and exits with an error
 code
 ******************************************************************************/
int main(int argc, char *argv[])
{
	/* local variables */
	int numItem = 0;
	int correctedValue;
	double actualVoltage;
	double actualValue;
	char *buffer;
	char *token;
	FILE *inputFIle;


	inputFIle = fopen(argv[1], "r");
	buffer = creatBuffer(BUFSIZE);
	/*read stdin line by line*/
	while(fgets(buffer, BUFSIZE, inputFIle) != NULL)
	{
		if(strcmp(buffer,"\n") && strcmp(buffer,"\r\n"))
		{
			numItem++;
			token = strtok(buffer, " ");
			/* reading token separated by spaces */
			actualVoltage = atof(token);
			token = strtok(NULL, " ");
			actualValue = atof(token);
			correctedValue = correct(actualValue);
			/* print to stdout */
			fprintf(stdout, "%f ", actualVoltage);
			fprintf(stdout, "%d\n", correctedValue);
		}
	}

	return NO_ERR;
}
コード例 #2
0
ファイル: aflDSound.cpp プロジェクト: mofon001/AflLib
//--------------------------------
// 同時発音用バッファの確保
//--------------------------------
void Sound::createList(int nCount,int bFlag)
{
	int i;
	if(!getWaveData()->isData())
		return;
	release();
	m_ppDSBuffer = NEW LPDIRECTSOUNDBUFFER[nCount];
	m_nCount = nCount;
//	if(bFlag == 0)
	{
		m_ppDSBuffer[0] = creatBuffer();
		for(i=1;i<m_nCount;i++)
			m_pDirectSound->DuplicateSoundBuffer(m_ppDSBuffer[0],&m_ppDSBuffer[i]);
	}

}
コード例 #3
0
ファイル: OALWav.cpp プロジェクト: Suvitruf/Android-ndk
void OALWav::loadWithStreaming(){
	this->curPos = 0;
	//f = AAssetFile(mgr, filename);

	if (f->null()) {
		LOGE("no file");
		return;
	}

	int res = f->read(&header,sizeof(BasicWAVEHeader),1);

	getFormat();


	//this->riffCount = (header.dataSize/(header.bitsPerSample/8));
	//this->riffSize = header.dataSize / this->riffCount;


	//this->riffSize = (header.bitsPerSample/8)*header.channels;
	/*int count = Min(RIFF_COUNT, this->riffCount -curPos);
	this->datas[currentBuff] = readRiffs(count );

	if(!this->datas[currentBuff])
		return;

	createBufferFromWave(datas[currentBuff],this->riffSize*(count ), 0);
	GenSources();*/
	//LogHeaders();
	source = 0;


	alGenBuffers(BUFF_COUNT, buffers);
	alGenSources(1, &source);
	buf = (unsigned char *)malloc(BUFFER_SIZE);
/*
	LOGI("source %i",source);
	for(int i=0;i<BUFF_COUNT;++i)
		LOGI("buf [%i] = %i",i,buffers[i]);*/

	if(alGetError() != AL_NO_ERROR){
		LOGI("Error generating :(\n");
		return;
	}


	for(int i=0;i<BUFF_COUNT;++i)
		creatBuffer(i);

	if(alGetError() != AL_NO_ERROR) {
	  LOGI("Error loading :(\n");
	  return ;
	}



	alSourceQueueBuffers(source, BUFF_COUNT, buffers);
	if(alGetError() != AL_NO_ERROR) {
		  LOGI("Error alSourceQueueBuffers :(\n");
		  return;
	}


	/*int count = Min(BUFFER_SIZE, this->riffCount -curPos);
	this->datas[currentBuff] = readRiffs(count );

	if(!this->datas[currentBuff])
		return;

	createBufferFromWave(datas[currentBuff],this->riffSize*(count ), 0);
	GenSources();*/
}