ToneGenerator

From SfzWiki
Revision as of 23:42, 16 August 2007 by Ghoulsblade (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
 openal : tone generator : 
 void cSoundSourceStream::StreamBuffer(ALuint buffer){
 	int size = STREAM_BUFFER_SIZE;
 	//int copied = mpStream->FillBuffer(b, size);
 	int copied = size;
 	int iTestTone = 16; // lower number = higher tone
 	for (int i=0;i<size/4;++i) {
 		float mysin = sin(float(i)/float(iTestTone));
 		signed short s = (signed short)( mysin * 0x1fff );
 		((signed short*)b)[i*2+0] = s;
 		((signed short*)b)[i*2+1] = s;
 	}
 	//for(int i=0;i<128;++i)printf("%i ",b[i]);printf("\n");
 	printf("copied=%i iTestTone=%d,freq=%i GetFrameSize=%d GetBitrate=%d GetChannels=%d\n",copied,iTestTone,(int)mpStream->GetFrequency(),(int)mpStream->GetFrameSize(),(int)mpStream->GetBitrate(),(int)mpStream->GetChannels());
 	
 	alBufferData(buffer, miBufferFormat, b, copied, mpStream->GetFrequency());
 	CheckOpenAl();
 }
 output : copied=65536 iTestTone=12,freq=44100 GetFrameSize=4 GetBitrate=16 GetChannels=2