Playback: Added FadeAndStop
This commit is contained in:
1 parent
a2f626fbca
commit
028eda099a
9 files changed
+66
-6
No files matched your search
@@ -166,7 +166,7 @@ namespace Vocaluxe.Base
|
||||
CDraw.RemoveTexture(ref _CurrentVideoTexture);
|
||||
_Video = -1;
|
||||
}
|
||||
CSound.FadeAndStop(_CurrentMusicStream, 0f, CSettings.BackgroundMusicFadeTime);
|
||||
CSound.FadeAndClose(_CurrentMusicStream, 0f, CSettings.BackgroundMusicFadeTime);
|
||||
_CurrentMusicStream = -1;
|
||||
|
||||
_CurrentPlaylistElement = new CPlaylistElement();
|
||||
|
||||
@@ -785,7 +785,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
public void FadeAndStop(int soundStream, float targetVolume, float duration)
|
||||
{
|
||||
CSound.FadeAndStop(soundStream, targetVolume, duration);
|
||||
CSound.FadeAndClose(soundStream, targetVolume, duration);
|
||||
}
|
||||
|
||||
public void SetStreamVolume(int soundStream, float volume)
|
||||
|
||||
@@ -122,11 +122,16 @@ namespace Vocaluxe.Base
|
||||
_Playback.FadeAndPause(stream, targetVolume, seconds);
|
||||
}
|
||||
|
||||
public static void FadeAndStop(int stream, float targetVolume, float seconds)
|
||||
public static void FadeAndClose(int stream, float targetVolume, float seconds)
|
||||
{
|
||||
_Playback.FadeAndClose(stream, targetVolume, seconds);
|
||||
}
|
||||
|
||||
public static void FadeAndStop(int stream, float targetVolume, float seconds)
|
||||
{
|
||||
_Playback.FadeAndStop(stream, targetVolume, seconds);
|
||||
}
|
||||
|
||||
public static void SetStreamVolume(int stream, float volume)
|
||||
{
|
||||
_Playback.SetStreamVolume(stream, volume);
|
||||
@@ -192,7 +197,7 @@ namespace Vocaluxe.Base
|
||||
int stream = Load(file);
|
||||
float length = GetLength(stream);
|
||||
Play(stream);
|
||||
FadeAndStop(stream, 100f, length);
|
||||
FadeAndClose(stream, 100f, length);
|
||||
return stream;
|
||||
}
|
||||
#endregion Sounds
|
||||
|
||||
@@ -159,5 +159,11 @@ namespace Vocaluxe.Lib.Sound
|
||||
{
|
||||
CGstreamerAudioWrapper.Update();
|
||||
}
|
||||
|
||||
|
||||
public void FadeAndStop(int stream, float targetVolume, float seconds)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -124,6 +124,13 @@ namespace Vocaluxe.Lib.Sound
|
||||
Streams[stream].FadeAndClose(targetVolume, seconds);
|
||||
}
|
||||
|
||||
public void FadeAndStop(int stream, float targetVolume, float seconds)
|
||||
{
|
||||
if (!Streams.ContainsKey(stream))
|
||||
return;
|
||||
Streams[stream].FadeAndStop(targetVolume, seconds);
|
||||
}
|
||||
|
||||
public void SetStreamVolume(int stream, float volume)
|
||||
{
|
||||
if (!Streams.ContainsKey(stream))
|
||||
@@ -205,6 +212,7 @@ namespace Vocaluxe.Lib.Sound
|
||||
private bool _Fading;
|
||||
private bool _CloseStreamAfterFade;
|
||||
private bool _PauseStreamAfterFade;
|
||||
private bool _StopStreamAfterFade;
|
||||
private Stopwatch _FadeTimer = new Stopwatch();
|
||||
private float _FadeTime;
|
||||
private float _FadeVolume;
|
||||
@@ -312,6 +320,12 @@ namespace Vocaluxe.Lib.Sound
|
||||
_CloseStreamAfterFade = true;
|
||||
}
|
||||
|
||||
public void FadeAndStop(float targetVolume, float seconds)
|
||||
{
|
||||
Fade(targetVolume, seconds);
|
||||
_StopStreamAfterFade = true;
|
||||
}
|
||||
|
||||
public float Volume
|
||||
{
|
||||
get
|
||||
@@ -412,9 +426,12 @@ namespace Vocaluxe.Lib.Sound
|
||||
Close();
|
||||
if (_PauseStreamAfterFade)
|
||||
Paused = true;
|
||||
if (_StopStreamAfterFade)
|
||||
Stop();
|
||||
|
||||
_CloseStreamAfterFade = false;
|
||||
_PauseStreamAfterFade = false;
|
||||
_StopStreamAfterFade = false;
|
||||
_Fading = false;
|
||||
_FadeTimer.Reset();
|
||||
}
|
||||
|
||||
@@ -345,6 +345,12 @@ namespace Vocaluxe.Lib.Sound
|
||||
_Context.Dispose();
|
||||
_Context = null;
|
||||
}
|
||||
|
||||
|
||||
public void FadeAndStop(int stream, float targetVolume, float seconds)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
class COpenAlStream : IDisposable
|
||||
|
||||
@@ -179,6 +179,18 @@ namespace Vocaluxe.Lib.Sound
|
||||
}
|
||||
|
||||
public void FadeAndClose(int stream, float targetVolume, float seconds)
|
||||
{
|
||||
if (_Initialized)
|
||||
{
|
||||
lock (_MutexDecoder)
|
||||
{
|
||||
if (_AlreadyAdded(stream))
|
||||
_Decoder[_GetStreamIndex(stream)].FadeAndClose(targetVolume, seconds, _Closeproc, stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void FadeAndStop(int stream, float targetVolume, float seconds)
|
||||
{
|
||||
if (_Initialized)
|
||||
{
|
||||
@@ -346,6 +358,7 @@ namespace Vocaluxe.Lib.Sound
|
||||
private float _StartVolume = 1f;
|
||||
private bool _CloseStreamAfterFade;
|
||||
private bool _PauseStreamAfterFade;
|
||||
private bool _StopStreamAfterFade;
|
||||
private bool _Fading;
|
||||
|
||||
private static CPortAudio.SPaHostApiInfo _ApiInfo;
|
||||
@@ -510,7 +523,7 @@ namespace Vocaluxe.Lib.Sound
|
||||
Fade(targetVolume, fadeTime);
|
||||
}
|
||||
|
||||
public void FadeAndStop(float targetVolume, float fadeTime, Closeproc closeProc, int streamID)
|
||||
public void FadeAndClose(float targetVolume, float fadeTime, Closeproc closeProc, int streamID)
|
||||
{
|
||||
_Closeproc = closeProc;
|
||||
_StreamID = streamID;
|
||||
@@ -519,10 +532,20 @@ namespace Vocaluxe.Lib.Sound
|
||||
Fade(targetVolume, fadeTime);
|
||||
}
|
||||
|
||||
public void FadeAndStop(float targetVolume, float fadeTime, Closeproc closeProc, int streamID)
|
||||
{
|
||||
_Closeproc = closeProc;
|
||||
_StreamID = streamID;
|
||||
_StopStreamAfterFade = true;
|
||||
|
||||
Fade(targetVolume, fadeTime);
|
||||
}
|
||||
|
||||
public void Play()
|
||||
{
|
||||
Paused = false;
|
||||
_PauseStreamAfterFade = false;
|
||||
_StopStreamAfterFade = false;
|
||||
lock (_Mutex)
|
||||
{
|
||||
_ErrorCheck("StartStream", CPortAudio.Pa_StartStream(_Ptr));
|
||||
@@ -921,6 +944,8 @@ namespace Vocaluxe.Lib.Sound
|
||||
|
||||
if (_PauseStreamAfterFade)
|
||||
Paused = true;
|
||||
if (_StopStreamAfterFade)
|
||||
Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace Vocaluxe.Lib.Sound
|
||||
void Fade(int stream, float targetVolume, float seconds);
|
||||
void FadeAndPause(int stream, float targetVolume, float seconds);
|
||||
void FadeAndClose(int stream, float targetVolume, float seconds);
|
||||
void FadeAndStop(int stream, float targetVolume, float seconds);
|
||||
void SetStreamVolume(int stream, float volume);
|
||||
void SetStreamVolumeMax(int stream, float volume);
|
||||
|
||||
|
||||
@@ -551,7 +551,7 @@ namespace Vocaluxe.Screens
|
||||
private void _CloseSong()
|
||||
{
|
||||
if (_CurrentStream > -1)
|
||||
CSound.FadeAndStop(_CurrentStream, 0f, 0.5f);
|
||||
CSound.FadeAndClose(_CurrentStream, 0f, 0.5f);
|
||||
CSound.RecordStop();
|
||||
if (_CurrentVideo != -1)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user