private void FMODrelease() { if (channel != null) { FMOD.Sound currentSound; FMOD.RESULT result = channel.getCurrentSound(out currentSound); if (result != FMOD.RESULT.ERR_CHANNEL_STOLEN) { ERRCHECK(result, "channel.getCurrentSound", false); if (currentSound == sound || currentSound == subSound) { result = channel.stop(); if (result != FMOD.RESULT.ERR_CHANNEL_STOLEN) { ERRCHECK(result, "channel.stop", false); } } } channel = null; } if (subSound != null) { FMOD.RESULT result = subSound.release(); ERRCHECK(result, "subSound.release", false); subSound = null; } if (sound != null) { FMOD.RESULT result = sound.release(); ERRCHECK(result, "sound.release", false); sound = null; } }
/// <summary> /// Initializes a new instance of <see cref="FMODChannel"/> and attempts to load all other values automatically /// <para/> /// The <see cref="FMODChannel.Sound"/> property is set to the one found via FMOD.Channel.getCurrentSound(ref FMOD.Sound) /// <para/> /// The <see cref="FMODChannel.Context"/> property is set to either the current context, or a new SynchronizationContext (if the current is not valid) /// </summary> /// <param name="channel"></param> /// <param name="id">The id of the channel</param> /// <param name="system">The <see cref="FMODSystem"/> that contains this channel</param> internal FMODChannel(FMODSystem system, FMOD.Channel channel, Guid id) { this.system = system; this.id = id; this.Channel = channel; FMOD.RESULT result = channel.getCurrentSound(ref this.sound); if (result != FMOD.RESULT.OK) { throw new FMODException("Unable to get current sound for Container", result); } }
private void timer_Tick(object sender, System.EventArgs e) { FMOD.RESULT result; uint ms = 0; uint lenms = 0; bool paused = false; bool playing = false; int channelsplaying = 0; if (channel != null) { FMOD.Sound currentsound = null; result = channel.isPlaying(ref playing); if ((result != FMOD.RESULT.OK) && (result != FMOD.RESULT.ERR_INVALID_HANDLE) && (result != FMOD.RESULT.ERR_CHANNEL_STOLEN)) { ERRCHECK(result); } result = channel.getPaused(ref paused); if ((result != FMOD.RESULT.OK) && (result != FMOD.RESULT.ERR_INVALID_HANDLE) && (result != FMOD.RESULT.ERR_CHANNEL_STOLEN)) { ERRCHECK(result); } result = channel.getPosition(ref ms, FMOD.TIMEUNIT.MS); if ((result != FMOD.RESULT.OK) && (result != FMOD.RESULT.ERR_INVALID_HANDLE) && (result != FMOD.RESULT.ERR_CHANNEL_STOLEN)) { ERRCHECK(result); } channel.getCurrentSound(ref currentsound); if (currentsound != null) { result = currentsound.getLength(ref lenms, FMOD.TIMEUNIT.MS); if ((result != FMOD.RESULT.OK) && (result != FMOD.RESULT.ERR_INVALID_HANDLE) && (result != FMOD.RESULT.ERR_CHANNEL_STOLEN)) { ERRCHECK(result); } } system.getChannelsPlaying(ref channelsplaying); } statusBar.Text = "Time " + (ms / 1000 / 60) + ":" + (ms / 1000 % 60) + ":" + (ms / 10 % 100) + "/" + (lenms / 1000 / 60) + ":" + (lenms / 1000 % 60) + ":" + (lenms / 10 % 100) + " " + (paused ? "Paused " : playing ? "Playing" : "Stopped") + " Channels Playing " + channelsplaying; if (system != null) { system.update(); } }