Ejemplo n.º 1
0
void StartRecording()
{
	WAVEFORMATEX *wf;
	if (recbuf) { // free old recording
		BASS_StreamFree(chan);
		chan=0;
		free(recbuf);
		recbuf=NULL;
		EnableWindow(DLGITEM(11),FALSE);
		EnableWindow(DLGITEM(12),FALSE);
		// close output device before recording incase of half-duplex device
		BASS_Free();
	}
	// allocate initial buffer and make space for WAVE header
	recbuf=malloc(BUFSTEP);
	reclen=44;
	// fill the WAVE header
	memcpy(recbuf,"RIFF\0\0\0\0WAVEfmt \20\0\0\0",20);
	memcpy(recbuf+36,"data\0\0\0\0",8);
	wf=(WAVEFORMATEX*)(recbuf+20);
	wf->wFormatTag=1;
	wf->nChannels=2;
	wf->wBitsPerSample=16;
	wf->nSamplesPerSec=44100;
	wf->nBlockAlign=wf->nChannels*wf->wBitsPerSample/8;
	wf->nAvgBytesPerSec=wf->nSamplesPerSec*wf->nBlockAlign;
	// start recording @ 44100hz 16-bit stereo
	if (!(rchan=BASS_RecordStart(44100,2,0,&RecordingCallback,0))) {
		Error("Couldn't start recording");
		free(recbuf);
		recbuf=0;
		return;
	}
	MESS(10,WM_SETTEXT,0,"Stop");
}
Ejemplo n.º 2
0
void UpdateInputInfo()
{
	char *type;
	float level;
	int it=BASS_RecordGetInput(input,&level); // get info on the input
	if (it==-1 || level<0) { // failed to get level
		BASS_RecordGetInput(-1,&level); // try master input instead
		if (level<0) { // that failed too
			level=1; // just display 100%
			EnableWindow(DLGITEM(14),FALSE);
		} else
			EnableWindow(DLGITEM(14),TRUE);
	} else
		EnableWindow(DLGITEM(14),TRUE);
	MESS(14,TBM_SETPOS,TRUE,level*100); // set the level slider
	switch (it&BASS_INPUT_TYPE_MASK) {
		case BASS_INPUT_TYPE_DIGITAL:
			type="digital";
			break;
		case BASS_INPUT_TYPE_LINE:
			type="line-in";
			break;
		case BASS_INPUT_TYPE_MIC:
			type="microphone";
			break;
		case BASS_INPUT_TYPE_SYNTH:
			type="midi synth";
			break;
		case BASS_INPUT_TYPE_CD:
			type="analog cd";
			break;
		case BASS_INPUT_TYPE_PHONE:
			type="telephone";
			break;
		case BASS_INPUT_TYPE_SPEAKER:
			type="pc speaker";
			break;
		case BASS_INPUT_TYPE_WAVE:
			type="wave/pcm";
			break;
		case BASS_INPUT_TYPE_AUX:
			type="aux";
			break;
		case BASS_INPUT_TYPE_ANALOG:
			type="analog";
			break;
		default:
			type="undefined";
	}
	MESS(15,WM_SETTEXT,0,type); // display the type
}
Ejemplo n.º 3
0
void StopRecording()
{
	BASS_ChannelStop(rchan);
	rchan=0;
	{ // complete the WAVE header
		DWORD len=ftell(rfp),v;
		fseek(rfp,4,SEEK_SET);
		v=len-8;
		fwrite(&v,1,4,rfp);
		fseek(rfp,40,SEEK_SET);
		v=len-44;
		fwrite(&v,1,4,rfp);
		fclose(rfp);
	}
	MESS(10,WM_SETTEXT,0,L"Record");
	// setup output device (using default device)
	if (!BASS_Init(-1,44100,0,NULL,NULL)) {
		Error(L"Can't initialize output device");
		return;
	}
	// create a stream from the recording
	if (chan=BASS_StreamCreateFile(FALSE,L"bass.wav",0,0,BASS_UNICODE))
		EnableWindow(DLGITEM(11),TRUE); // enable "play" button
	else 
		BASS_Free();
}
Ejemplo n.º 4
0
void StartRecording()
{
	WAVEFORMATEX wf;
	if (chan) { // free old recording
		BASS_StreamFree(chan);
		chan=0;
		EnableWindow(DLGITEM(11),FALSE);
		// close output device before recording incase of half-duplex device
		BASS_Free();
	}
	// open the output file
	if (!(rfp=_wfopen(L"bass.wav",L"wb"))) {
		Error(L"Can't create the file");
		return;
	}
	// write the WAVE header
	fwrite("RIFF\0\0\0\0WAVEfmt \20\0\0\0",1,20,rfp);
	wf.wFormatTag=WAVE_FORMAT_PCM;
	wf.nChannels=1;
	wf.wBitsPerSample=16;
	wf.nSamplesPerSec=44100;
	wf.nBlockAlign=wf.nChannels*wf.wBitsPerSample/8;
	wf.nAvgBytesPerSec=wf.nSamplesPerSec*wf.nBlockAlign;
	fwrite(&wf,1,16,rfp);
	fwrite("data\0\0\0\0",1,8,rfp);
	// start recording @ 44100hz 16-bit mono
	if (!(rchan=BASS_RecordStart(44100,1,0,&RecordingCallback,0))) {
		Error(L"Couldn't start recording");
		fclose(rfp);
		return;
	}
	MESS(10,WM_SETTEXT,0,L"Stop");
}
Ejemplo n.º 5
0
void StopRecording()
{
	BASS_ChannelStop(rchan);
	rchan=0;
	MESS(10,WM_SETTEXT,0,"Record");
	// complete the WAVE header
	*(DWORD*)(recbuf+4)=reclen-8;
	*(DWORD*)(recbuf+40)=reclen-44;
	// enable "save" button
	EnableWindow(DLGITEM(12),TRUE);
	// setup output device (using default device)
	if (!BASS_Init(-1,FREQ,0,win,NULL)) {
		Error("Can't initialize output device");
		return;
	}
	// create a stream from the recording
	if (chan=BASS_StreamCreateFile(TRUE,recbuf,0,reclen,0))
		EnableWindow(DLGITEM(11),TRUE); // enable "play" button
	else 
		BASS_Free();
}