Exemplo n.º 1
0
void BASS_AudioInterface::insertData(float* data,int nSamples)
{
	
	for (int i=0;i<nSamples;i++)
	{
		if (mBuffSize < mMaxBuffSize)
		{
			mTempBuffer[mBuffSize++] = data[i];

		}
		
		if (mBuffSize == mFreq * mNumChannels / 10) {

			DWORD err = BASS_StreamPutData(mStream, mTempBuffer, mBuffSize * 4);
	
			mBuffSize = 0;
			
			DWORD state = BASS_ChannelIsActive(mStream);
	
			if (state != BASS_ACTIVE_PLAYING) {
				BASS_ChannelPlay(mStream, 0);
			}
		
		}
	
	}
		
}
Exemplo n.º 2
0
BOOL CALLBACK RecordingCallback(HRECORD handle, const void *buffer, DWORD length, void *user)
{
	DWORD bl;
	BASS_StreamPutData(chan,buffer,length); // feed recorded data to output stream
	bl=BASS_ChannelGetData(chan,NULL,BASS_DATA_AVAILABLE); // get output buffer level
	if (prebuf) { // prebuffering
		if (bl>=prebuf+length) { // gone 1 block past the prebuffering target
#ifdef ADJUSTRATE
			targbuf=bl; // target the current level
			prevbuf=0;
#endif
			prebuf=0; // finished prebuffering
			BASS_ChannelPlay(chan,FALSE); // start the output
		}
	} else { // playing
#ifdef ADJUSTRATE
		if (bl<targbuf) { // buffer level is below target, slow down...
			rate--;
			BASS_ChannelSetAttribute(chan,BASS_ATTRIB_FREQ,rate);
			prevbuf=0;
		} else if (bl>targbuf && bl>=prevbuf) { // buffer level is high and not falling, speed up...
			rate++;
			BASS_ChannelSetAttribute(chan,BASS_ATTRIB_FREQ,rate);
			prevbuf=bl;
		}
#endif
	}
	return TRUE; // continue recording
}
Exemplo n.º 3
0
void Player::push(void *data, uint32_t size) {
    int buffered = BASS_ChannelGetData(_output, NULL, BASS_DATA_AVAILABLE);
    Log::msg("In buffer: %d - New: %d", buffered, size);
    
	if(BASS_StreamPutData(_output, data, size) == (DWORD)-1)
		Log::error("Bass Error: putting stream data failed: %s", GetBassStrError());
}
Exemplo n.º 4
0
//
// Util use in BeginLoadingMedia
//
HSTREAM CBassAudio::ConvertFileToMono(const SString& strPath)
{
    HSTREAM decoder = BASS_StreamCreateFile ( false, strPath, 0, 0, BASS_STREAM_DECODE | BASS_SAMPLE_MONO ); // open file for decoding
    if ( !decoder )
        return 0; // failed
    DWORD length = static_cast <DWORD> ( BASS_ChannelGetLength ( decoder, BASS_POS_BYTE ) ); // get the length
    void *data = malloc ( length ); // allocate buffer for decoded data
    BASS_CHANNELINFO ci;
    BASS_ChannelGetInfo ( decoder, &ci ); // get sample format
    if ( ci.chans > 1 ) // not mono, downmix...
    {
        HSTREAM mixer = BASS_Mixer_StreamCreate ( ci.freq, 1, BASS_STREAM_DECODE | BASS_MIXER_END ); // create mono mixer
        BASS_Mixer_StreamAddChannel ( mixer, decoder, BASS_MIXER_DOWNMIX | BASS_MIXER_NORAMPIN | BASS_STREAM_AUTOFREE ); // plug-in the decoder (auto-free with the mixer)
        decoder = mixer; // decode from the mixer
    }
    length = BASS_ChannelGetData ( decoder, data, length ); // decode data
    BASS_StreamFree ( decoder ); // free the decoder/mixer
    HSTREAM stream = BASS_StreamCreate ( ci.freq, 1, BASS_STREAM_AUTOFREE, STREAMPROC_PUSH, NULL ); // create stream
    BASS_StreamPutData ( stream, data, length ); // set the stream data
    free ( data ); // free the buffer
    return stream;
}
Exemplo n.º 5
0
BOOL CALLBACK RecordingCallback(HRECORD handle, const void *buffer, DWORD length, void *user)
{
	BASS_StreamPutData(chan,buffer,length); // feed recorded data to output stream
	return TRUE; // continue recording
}
Exemplo n.º 6
0
void CALLBACK CustFXDSPProc (HFX hfx, DWORD chan, void* buf, DWORD len, HCustFX* hc) {
BASS_StreamPutData(hc->push, buf, len);
BASS_ChannelGetData(hc->pitch, buf, len);
}
Exemplo n.º 7
0
void Player::push(void *data, uint32_t size) {
	if(BASS_StreamPutData(_output, data, size) == (DWORD)-1)
		std::cerr << "Bass Error: putting stream data failed: " << BASS_ErrorGetCode() << "\n";

	_pos += size/sizeof(int16_t);
}