Esempio n. 1
0
/**
 * Initiate the playing of a sound resource.
 * @param resnum Resource number
 */
void SoundGen2GS::play(int resnum) {
	AgiSoundEmuType type;

	_playingSound = resnum;

	type = (AgiSoundEmuType)_vm->_game.sounds[resnum]->type();
	assert (type == AGI_SOUND_SAMPLE || type == AGI_SOUND_MIDI);

	if (_vm->_soundemu != SOUND_EMU_APPLE2GS) {
		warning("Trying to play sample or MIDI resource but not using Apple IIGS sound emulation mode");
		return;
	}

	haltGenerators();

	switch (type) {
	case AGI_SOUND_SAMPLE: {
		IIgsSample *sampleRes = (IIgsSample *) _vm->_game.sounds[_playingSound];
		const IIgsSampleHeader &header = sampleRes->getHeader();
		_channels[kSfxMidiChannel].setInstrument(&header.instrument);
		_channels[kSfxMidiChannel].setVolume(header.volume);
		midiNoteOn(kSfxMidiChannel, header.pitch, 127);
		break;
	}
	case AGI_SOUND_MIDI:
		((IIgsMidi *) _vm->_game.sounds[_playingSound])->rewind();
		_ticks = 0;
		break;
	default:
		break;
	}
}
Esempio n. 2
0
void SoundGen2GS::play(int resnum) {
	AgiSoundEmuType type;

	_playingSound = resnum;

	type = (AgiSoundEmuType)_vm->_game.sounds[resnum]->type();

	assert (type == AGI_SOUND_SAMPLE || type == AGI_SOUND_MIDI);

	switch (type) {
	case AGI_SOUND_SAMPLE: {
		IIgsSample *sampleRes = (IIgsSample *) _vm->_game.sounds[_playingSound];
		playSampleSound(sampleRes->getHeader(), sampleRes->getSample());
		break;
	}
	case AGI_SOUND_MIDI:
		((IIgsMidi *) _vm->_game.sounds[_playingSound])->rewind();
		break;
	default:
		break;
	}
}