Exemplo n.º 1
0
void MidiPlayer::send(uint32 b) {
	byte volume, ch = (byte)(b & 0xF);
	debugC(9, kDebugMusic, "MidiPlayer::send, channel %d (volume is %d)", ch, _channelsVolume[ch]);
	switch (b & 0xFFF0) {
	case 0x07B0:                                    // volume change
		volume = (byte)((b >> 16) & 0x7F);
		_channelsVolume[ch] = volume;
		volume = volume * _masterVolume / 255;
		b = (b & 0xFF00FFFF) | (volume << 16);
		debugC(8, kDebugMusic, "Volume change, channel %d volume %d", ch, volume);
		break;
	case 0x7BB0:                                    // all notes off
		debugC(8, kDebugMusic, "All notes off, channel %d", ch);
		if (!_channelsTable[ch]) {                  // channel not yet allocated, no need to send the event
			return;
		}
		break;
	}

	if (!_channelsTable[ch]) {
		_channelsTable[ch] = (ch == 9) ? _driver->getPercussionChannel() : _driver->allocateChannel();
		if (_channelsTable[ch])
			setChannelVolume(ch);
	}
	if (_channelsTable[ch]) {
		_channelsTable[ch]->send(b);
	}
}
Exemplo n.º 2
0
	void playSound(uint8_t channel, int volume, Mix_Chunk *chunk, int loops = 0) {
		stopSound(channel);
		if (chunk) {
			Mix_PlayChannel(channel, chunk, loops);
		}
		setChannelVolume(channel, volume);
		_sounds[channel] = chunk;
	}
Exemplo n.º 3
0
int QSoundManager::playWave(CWaveFile *waveFile, int iChannel, uint flags, CProximity &prox) {
	if (!waveFile || !waveFile->isLoaded())
		return 0;

	prox._channelVolume = CLIP(prox._channelVolume, 0, 100);
	prox._balance = CLIP(prox._balance, -100, 100);

	int slotIndex = findFreeSlot();
	if (slotIndex == -1)
		return -1;

	// Set the volume
	setChannelVolume(iChannel, prox._channelVolume, prox._channelMode);

	switch (prox._positioningMode) {
	case POSMODE_POLAR:
		qsWaveMixSetPolarPosition(iChannel, 8, QSPOLAR(prox._azimuth, prox._range, prox._elevation));
		qsWaveMixEnableChannel(iChannel, QMIX_CHANNEL_ELEVATION, true);
		qsWaveMixSetDistanceMapping(iChannel, 8, QMIX_DISTANCES(5.0, 3.0, 1.0));
		break;

	case POSMODE_VECTOR:
		qsWaveMixSetSourcePosition(iChannel, 8, QSVECTOR(prox._posX, prox._posY, prox._posZ));
		qsWaveMixEnableChannel(iChannel, QMIX_CHANNEL_ELEVATION, true);
		qsWaveMixSetDistanceMapping(iChannel, 8, QMIX_DISTANCES(5.0, 3.0, 1.0));
		break;

	default:
		qsWaveMixEnableChannel(iChannel, QMIX_CHANNEL_ELEVATION, true);
		qsWaveMixSetPolarPosition(iChannel, 8, QSPOLAR(0.0, 1.0, 0.0));
		break;
	}

	if (prox._frequencyMultiplier || prox._frequencyAdjust != 1.875) {
		uint freq = (uint)(waveFile->getFrequency() * prox._frequencyMultiplier);
		qsWaveMixSetFrequency(iChannel, 8, freq);
	}

	_sounds.add(waveFile, iChannel, prox._endTalkerFn, prox._talker);

	QMIXPLAYPARAMS playParams;
	playParams.callback = soundFinished;
	playParams.dwUser = this;
	if (!qsWaveMixPlayEx(iChannel, flags, waveFile, prox._repeated ? -1 : 0, playParams)) {
		Slot &slot = _slots[slotIndex];
		slot._handle = _handleCtr++;
		slot._channel = iChannel;
		slot._waveFile = waveFile;
		slot._positioningMode = prox._positioningMode;

		return slot._handle;
	} else {
		_sounds.flushChannel(waveFile, iChannel);
		if (prox._disposeAfterUse == DisposeAfterUse::YES)
			delete waveFile;
		return 0;
	}
}
Exemplo n.º 4
0
void FModSound::setAllChannelsVolume(Real32 volume)
{
    for(ChannelMap::iterator SearchItor = _ChannelMap.begin() ;
        SearchItor != _ChannelMap.end() ;
        ++SearchItor)
    {
        setChannelVolume(volume, SearchItor->first);
    }
}
Exemplo n.º 5
0
void MidiPlayer::setVolume(int volume) {
	Common::StackLock lock(_mutex);

	volume = CLIP(volume, 0, 255);
	if (_masterVolume == volume)
		return;
	_masterVolume = volume;

	for (int i = 0; i < 16; ++i) {
		if (_channel[i]) {
			setChannelVolume(i);
		}
	}
}
Exemplo n.º 6
0
void setup(void)
{
	// setup 1KHz timer
	setupTimer();	
	
	// init LCD
	LCD_init();
	
	// init PPS
	// SPKR thru PPS
	pinMode(OUTPUTPIN,OUTPUT);
	pinModePPS(OUTPUTPIN,HIGH);
	outputPinForFunction( OUTPUTPIN, 14); 	
	
	/* set all the channels to same frequency, max level, no noise */
	/*unsigned int slots[] = { 10, 11 };
	unsigned int i;
	ym2149_channel_t chan;

	for (i = 0; i < sizeof(slots) / sizeof(slots[0]); ++i)
	{
		
		// select the YM module
		setDeviceSlot(slots[i]);

		for (chan = YM2149_CH_A; chan < YM2149_CH_MAX; ++chan)
		{
			setChannelFrequency(chan, 0x0500);
			setChannelMixerNoise(chan, 1); // 1 means disabled
			setChannelMixerTone(chan, 0);
			setChannelVolume(chan, 0x0f);
		}
	}*/


	setDeviceSlot(10);
	setChannelFrequency(YM2149_CH_C, 0x0500);
	setChannelMixerNoise(YM2149_CH_C, 1); // 1 means disabled
	setChannelMixerTone(YM2149_CH_C, 0);
	setChannelVolume(YM2149_CH_C, 0x0f);

	pokey_setDeviceSlot(12); 
	pokey_channel_t pokchan;
	for (pokchan = POKEY_CH_A; pokchan < POKEY_CH_D; ++pokchan) 
	{ 
		pokey_setChannelPeriodMultiplier(pokchan, 0x90); 
		pokey_setChannelControl(pokchan, 0x00); 	 
	}
	pokey_setAudioCtrl(0x0);
}
Exemplo n.º 7
0
void Infogrames::interrupt() {
	int chn;

	if (!_data) {
		clearVoices();
		return;
	}

	_speedCounter--;
	_sample = 0xFF;
	for (chn = 0; chn < 4; chn++) {
		_volume = 0;
		_period = 0;
		getNextSample(_chn[chn]);
		setChannelVolume(chn, _volume);
		setChannelPeriod(chn, _period);
		if ((_sample != 0xFF) && (_sample < _instruments->_count)) {
			setChannelData(chn,
			               _instruments->_samples[_sample].data,
			               _instruments->_samples[_sample].dataRepeat,
			               _instruments->_samples[_sample].length,
			               _instruments->_samples[_sample].lengthRepeat);
			_sample = 0xFF;
		}
	}
	if (_speedCounter == 0)
		_speedCounter = _speed;

	// End reached?
	if ((_chn[0].flags & 64) && (_chn[1].flags & 64) &&
			(_chn[2].flags & 64) && (_chn[3].flags & 64)) {
		if (_repCount > 0) {
			_repCount--;
			init();
		} else if (_repCount != -1) {
			stopPaula();
		} else {
			init();
		}
	}
}
Exemplo n.º 8
0
GameSound::GameSound()
{
  // load sounds
  QString sndpath = GameWidget::getResourcePath() + "sounds/";

  loadSound(sndpath + "disappear.wav");
  loadSound(sndpath + "smallhammer.wav");
  loadSound(sndpath + "unblock.wav");
  loadSound(sndpath + "hammer.wav");
  loadSound(sndpath + "bighammer.wav");
  loadSound(sndpath + "bomb.wav");
  loadSound(sndpath + "row.wav");
  loadSound(sndpath + "randomkill.wav");
  loadSound(sndpath + "mixer.wav");
  loadSound(sndpath + "twin.wav");
  loadSound(sndpath + "clock.wav");
  loadSound(sndpath + "bonusend.wav");
  loadSound(sndpath + "newitem.wav");
  loadSound(sndpath + "target.wav");
  loadSound(sndpath + "levelstart.wav");
  loadSound(sndpath + "levelfail.wav");
  loadSound(sndpath + "levelwon.wav");
  loadSound(sndpath + "beep.wav");
  loadSound(sndpath + "bonus.wav");
  loadSound(sndpath + "newtool.wav");

  // music
  music = 0;
  musicEnabled = false;
  musicPlaying = false;

  myTimer = new QTimer(this);
  myTimer->setInterval(1000);
  connect(myTimer, SIGNAL(timeout()), this, SLOT(checkPlayMusic()));
  myTimer->stop();

  // setup volume
  setChannelVolume(MIX_MAX_VOLUME);
  setMusicVolume(MIX_MAX_VOLUME/4);
}