示例#1
0
void cSoundEffect::release()
{
	for(vector<HSAMPLE>::iterator i = m_vecSamples.begin(); i != m_vecSamples.end(); i++)
	{
		BASS_SampleFree(*i);
	}

	m_vecSamples.clear();
}
示例#2
0
文件: 3dtest.c 项目: adius/FeetJ
void RemoveClicked(GtkButton *obj, gpointer data)
{ // remove a channel
	GtkTreeModel *tm=gtk_tree_view_get_model(GTK_TREE_VIEW(GetWidget("channels")));
	GtkTreeIter it;
	if (gtk_tree_model_iter_nth_child(tm,&it,NULL,chan)) {
		Channel *c=chans+chan;
		// free both MOD and stream, it must be one of them! :)
		BASS_SampleFree(c->channel);
		BASS_MusicFree(c->channel);
		chanc--;
		memmove(c,c+1,(chanc-chan)*sizeof(Channel));
		gtk_list_store_remove(GTK_LIST_STORE(tm),&it);
	}
}
示例#3
0
void BassSoundEngine::Clear()
{
	StopAllMusic();

	for( auto ptr = sample_pool.begin(); ptr != sample_pool.end(); ptr++ )
		BASS_SampleFree( ptr->second );
	sample_pool.clear();

	for( auto ptr = stream_pool.begin(); ptr != stream_pool.end(); ptr++ )
		BASS_StreamFree( ptr->second );
	stream_pool.clear();

	memset(channel,0,sizeof(channel));
	nowChannel = 0;
	intended_pitch = 1.0;
}
示例#4
0
ClientGame::~ClientGame()
{

    BASS_StreamFree(m_music);
    BASS_SampleFree(m_soundAction);
    BASS_SampleFree(m_soundDeath);
    BASS_SampleFree(m_soundDrop);
    BASS_SampleFree(m_soundHack);
    BASS_SampleFree(m_soundPickup);
    BASS_SampleFree(m_soundTrain);

    if (m_server)
    {
        delete m_server;
        m_server = NULL;
    }

}
示例#5
0
void LoadedSample::End ()
{
    BASS_SampleFree(m_sample);
}
示例#6
0
void freeSound (int a) {
	BASS_SampleFree(soundCache[a].sample);
	soundCache[a].sample = NULL;
	soundCache[a].fileLoaded = -1;
	soundCache[a].looping = false;
}
AudioClip::~AudioClip()
{
	if (hm) BASS_SampleFree(hm);
}
示例#8
0
static bool Configure(SoundTemplate &self, const tinyxml2::XMLElement *element, unsigned int id)
{
	const char *name = element->Attribute("name");
	if (name == NULL)
		return false;

#if defined(USE_BASS)

	// load sound file
	HSAMPLE handle = BASS_SampleLoad(false, name, 0, 0, 1, BASS_SAMPLE_MONO);
	if (!handle)
	{
		DebugPrint("error loading sound file \"%s\": %s\n", name, BASS_ErrorGetString());
		return false;
	}

	// get sample info
	BASS_SAMPLE info;
	BASS_SampleGetInfo(handle, &info);

	// allocate space for data
	self.Reserve(info.length / info.chans);

	// set frequency
	self.mFrequency = info.freq;

	// if converting format...
	if ((info.chans > 1) || (info.flags & BASS_SAMPLE_8BITS))
	{
		// get sample data
		void *buf = _alloca(info.length);
		BASS_SampleGetData(handle, buf);

		// if converting from 8-bit...
		int accum = 0;
		if (info.flags & BASS_SAMPLE_8BITS)
		{
			for (unsigned int in = 0, samp = 0; in < info.length; ++in)
			{
				accum += static_cast<unsigned char *>(buf)[in];
				if (++samp >= info.chans)
				{
					self.Append(short(accum * 257 / samp - 32768));
					accum = 0;
					samp = 0;
				}
			}
		}
		else
		{
			for (unsigned int in = 0, samp = 0; in < info.length / sizeof(short); ++in)
			{
				accum += static_cast<short *>(buf)[in];
				if (++samp >= info.chans)
				{
					self.Append(short(accum / samp));
					accum = 0;
					samp = 0;
				}
			}
		}
	}
	else
	{
		// copy sound data
		BASS_SampleGetData(handle, static_cast<short *>(self.mData) + self.mLength);
	}

	// free loaded data
	BASS_SampleFree(handle);

#elif defined(USE_SDL_MIXER)

	// load sound file
	Mix_Chunk *loadchunk = Mix_LoadWAV(name);
	if (!loadchunk)
	{
		DebugPrint("error loading sound file \"%s\": %s\n", name, Mix_GetError());
		return false;
	}

	// copy sound data
	self.mSize = self.mLength * sizeof(short) + loadchunk->alen;
	self.mData = realloc(self.mData, self.mSize);
	memcpy(static_cast<short *>(self.mData) + self.mLength, loadchunk->abuf, loadchunk->alen);
	self.mLength = self.mSize / sizeof(short);

	// free loaded data
	Mix_FreeChunk(loadchunk);

#elif defined(USE_SDL)

	// load wave file data
	SDL_AudioSpec wave;
	Uint8 *data;
	Uint32 dlen;
	if ( !SDL_LoadWAV(name, &wave, &data, &dlen) )
	{
		DebugPrint("error loading sound file \"%s\": %s\n", name, SDL_GetError());
		return false;
	}

	// build audio conversion
	SDL_AudioCVT cvt;
	SDL_BuildAudioCVT(&cvt, wave.format, wave.channels, wave.freq,
							AUDIO_S16,   1,             AUDIO_FREQUENCY);

	// append sound data
	self.mSize = self.mLength * sizeof(short) + dlen * cvt.len_mult;
	self.mData = realloc(self.mData, self.mSize);
	memcpy(static_cast<short *>(self.mData) + self.mLength, data, dlen);
	cvt.buf = reinterpret_cast<unsigned char *>(static_cast<short *>(mData) + mLength);
	cvt.len = dlen;

	// convert to final format
	SDL_ConvertAudio(&cvt);
	self.mLength += cvt.len_cvt / sizeof(short);
	self.mSize = self.mLength * sizeof(short);
	self.mData = realloc(self.mData, self.mSize);

	// release wave file data
	SDL_FreeWAV(data);

#endif

	return true;
}