예제 #1
0
void setSoundVolume (int a, int v) {
	if (soundOK) {
		int ch = findInSoundCache (a);
		if (ch != -1) {
			if (BASS_ChannelIsActive (soundCache[ch].mostRecentChannel))
			{
				BASS_ChannelSetAttribute (soundCache[ch].mostRecentChannel, BASS_ATTRIB_VOL, (float) v / 255);
			}
		}
	}
}
예제 #2
0
void setSoundVolume (int a, int v) {
	if (! soundOK) return;
	int ch = findInSoundCache (a);
	if (ch != -1) {
		if (soundCache[ch].playing) {
			soundCache[ch].vol = v;
			alSourcef (soundCache[ch].playingOnSource,
					AL_GAIN, (float) v / 256);
		}
	}
}
예제 #3
0
int cacheSound (int f) {
	setResourceForFatal (f);

	if (! soundOK) return 0;

	int a = findInSoundCache (f);
	if (a != -1) return a;
	if (f == -2) return -1;
	a = findEmptySoundSlot ();
	freeSound (a);

	uint32_t length = openFileFromNum (f);
	if (! length) return -1;

	char * memImage;

	bool tryAgain = true;

	while (tryAgain) {
		memImage = loadEntireFileToMemory (bigDataFile, length);
		tryAgain = memImage == NULL;
		if (tryAgain) {
			if (! forceRemoveSound ()) {
				fatal (ERROR_SOUND_MEMORY_LOW);
				return -1;
			}
		}
	}

	for (;;) {
//		soundWarning ("  Trying to load sound into slot", a);
		soundCache[a].sample = BASS_SampleLoad(true, memImage, 0, length, 65535, 0);

		if (soundCache[a].sample) {
			soundCache[a].fileLoaded = f;
			delete memImage;
			setResourceForFatal (-1);
			return a;
		}

		warning (ERROR_SOUND_ODDNESS);
		soundCache[a].sample = NULL;
		soundCache[a].fileLoaded = -1;
		soundCache[a].looping = false;
		return -1;
	}
}
예제 #4
0
void huntKillSound (int filenum) {
	if (! soundOK) return;
	// Clear OpenAL errors to make sure they don't block anything:
	alGetError();

	int gotSlot = findInSoundCache (filenum);
	if (gotSlot == -1) return;

	SilenceIKillYou = true;

	if (soundCache[gotSlot].playing) {
		if (! alureStopSource(soundCache[gotSlot].playingOnSource, AL_TRUE)) {
			debugOut("Failed to stop source: %s\n",
						alureGetErrorString());
		}
	}

	SilenceIKillYou = false;
}
예제 #5
0
bool runSludge () {

	loadedFunction * thisFunction = allRunningFunctions;
	loadedFunction * nextFunction;

	while (thisFunction) {
		nextFunction = thisFunction -> next;

		if (! thisFunction -> freezerLevel) {
			if (thisFunction -> timeLeft) {
				if (thisFunction -> timeLeft < 0) {
					if (! stillPlayingSound (findInSoundCache (speech -> lastFile))) {
						thisFunction -> timeLeft = 0;
					}
				} else if (! -- (thisFunction -> timeLeft)) {
				}
			} else {
				if (thisFunction -> isSpeech) {
					thisFunction -> isSpeech = false;
					killAllSpeech ();
				}
				if (! continueFunction (thisFunction))
					return false;
			}
		}

		thisFunction = nextFunction;
	}

	if (loadNow) {
		if (loadNow[0] == ':') {
			saveGame (loadNow + 1);
			setVariable (saverFunc -> reg, SVT_INT, 1);
		} else {
			if (! loadGame (loadNow)) return false;
		}
		delete loadNow;
		loadNow = NULL;
	}

	return true;
}
예제 #6
0
void huntKillFreeSound (int filenum) {
	int gotSlot = findInSoundCache (filenum);
	if (gotSlot != -1) freeSound (gotSlot);
}
예제 #7
0
void huntKillSound (int filenum) {
	int gotSlot = findInSoundCache (filenum);
	if (gotSlot == -1) return;
	soundCache[gotSlot].looping = false;
	BASS_SampleStop (soundCache[gotSlot].sample);
}
예제 #8
0
int cacheSound (int f) {
	if (! soundOK) return -1;

	unsigned int chunkLength;
	int retval;
	bool loopy;

	loopy = cacheLoopySound;
	cacheLoopySound = false;

	setResourceForFatal (f);

	if (! soundOK) return 0;

	int a = findInSoundCache (f);
	if (a != -1) {
		if (soundCache[a].playing) {
			if (! alureStopSource(soundCache[a].playingOnSource, AL_TRUE)) {
				debugOut( "Failed to stop source: %s\n",
							alureGetErrorString());
			}
		}
		if (! alureRewindStream (soundCache[a].stream)) {
			debugOut( "Failed to rewind stream: %s\n",
						alureGetErrorString());
		}

		return a;
	}
	if (f == -2) return -1;
	a = findEmptySoundSlot ();
	freeSound (a);

	uint32_t length = openFileFromNum (f);
	if (! length) return -1;

	unsigned char * memImage;

	bool tryAgain = true;

	while (tryAgain) {
		memImage = (unsigned char*)loadEntireFileToMemory (bigDataFile, length);
		tryAgain = memImage == NULL;
		if (tryAgain) {
			if (! forceRemoveSound ()) {
				fatal (ERROR_SOUND_MEMORY_LOW);
				return -1;
			}
		}
	}

	chunkLength = 19200;

	// Small looping sounds need small chunklengths.
	if (loopy) {
		if (length < NUM_BUFS * chunkLength) {
			chunkLength = length / NUM_BUFS;
		}
	} else if (length < chunkLength) {
		chunkLength = length;
	}

	soundCache[a].stream = alureCreateStreamFromMemory(memImage, length, chunkLength, 0, NULL);

	delete memImage;

	if (soundCache[a].stream != NULL) {
		soundCache[a].fileLoaded = f;
		setResourceForFatal (-1);
		retval = a;
	} else {
		debugOut("Failed to create stream from sound: %s\n",
						alureGetErrorString());
		warning (ERROR_SOUND_ODDNESS);
		soundCache[a].stream = NULL;
		soundCache[a].playing = false;
		soundCache[a].playingOnSource = 0;
		soundCache[a].fileLoaded = -1;
		soundCache[a].looping = false;
		retval = -1;
	}

	return retval;
}
예제 #9
0
void huntKillFreeSound (int filenum) {
	if (! soundOK) return;
	int gotSlot = findInSoundCache (filenum);
	if (gotSlot == -1) return;
	freeSound (gotSlot);
}