public bool PlaySound(uint channelIndex, uint soundIndex, float volume, byte pan, uint offset = 0) { channelIndex %= MAX_CHANNEL; if ((soundIndex >= MAX_SOUND) || (channelIndex >= MAX_CHANNEL)) { return(false); } FMODEX.Channel channel = _channels[channelIndex]; if (channel != null) { bool isPlaying = false; FMODEX.RESULT iresult = channel.isPlaying(ref isPlaying); if (iresult == FMODEX.RESULT.OK && isPlaying) { //channel.stop(); //channel.setPaused(true); } } if (m_sounds[soundIndex] == null) { return(false); } // convert pan settings float fpan = 0; if (64 < (int)pan) { fpan = (float)(((double)pan - 64.0) / 63.0); } else { fpan = (float)(((double)pan - 64.0) / 64.0); } FMODEX.Channel chan = null; FMODEX.RESULT result = m_system.playSound(FMODEX.CHANNELINDEX.FREE, m_sounds[soundIndex], true, ref _channels[channelIndex]); if (result == FMODEX.RESULT.OK) { chan = _channels[channelIndex]; chan.setVolume(volume); chan.setPan(fpan); chan.setPaused(false); if (offset != 0) { Logs.Write("Seek sound {0} to position {1} ms", soundIndex, offset); chan.setPosition(offset, FMODEX.TIMEUNIT.PCM); } } return(result == FMODEX.RESULT.OK); }
public bool SetVolume(uint channelIndex, float volume) { channelIndex %= MAX_CHANNEL; FMODEX.Channel channel = _channels[channelIndex]; if (channel == null) { return(false); } FMODEX.RESULT result = channel.setVolume(volume); return(result == FMODEX.RESULT.OK); }