added FadeAndPause.
you can test in in screen test (T in main screen), just add a "Test.mp3" to Output folder.
This commit is contained in:
1 parent
9a6f1f541a
commit
5fb3280a81
8 files changed
+156
No files matched your search
@@ -101,6 +101,11 @@ namespace Vocaluxe.Base
|
||||
_Playback.Fade(Stream, TargetVolume, Seconds);
|
||||
}
|
||||
|
||||
public static void FadeAndPause(int Stream, float TargetVolume, float Seconds)
|
||||
{
|
||||
_Playback.FadeAndPause(Stream, TargetVolume, Seconds);
|
||||
}
|
||||
|
||||
public static void FadeAndStop(int Stream, float TargetVolume, float Seconds)
|
||||
{
|
||||
_Playback.FadeAndStop(Stream, TargetVolume, Seconds);
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace Vocaluxe.Lib.Sound
|
||||
private bool _Initialized = false;
|
||||
private List<AudioStreams> _Streams;
|
||||
private SYNCPROC _SyncSlideAndStop;
|
||||
private SYNCPROC _SyncSlideAndPause;
|
||||
private Object MutexAudioStreams = new Object();
|
||||
|
||||
|
||||
@@ -48,6 +49,7 @@ namespace Vocaluxe.Lib.Sound
|
||||
ok = Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
|
||||
_Streams = new List<AudioStreams>();
|
||||
_SyncSlideAndStop = new SYNCPROC(EndSync);
|
||||
_SyncSlideAndPause = new SYNCPROC(PauseSync);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -219,6 +221,22 @@ namespace Vocaluxe.Lib.Sound
|
||||
}
|
||||
}
|
||||
|
||||
public void FadeAndPause(int Stream, float TargetVolume, float Seconds)
|
||||
{
|
||||
if (_Initialized)
|
||||
{
|
||||
lock (MutexAudioStreams)
|
||||
{
|
||||
if (AlreadyAdded(Stream))
|
||||
{
|
||||
Bass.BASS_ChannelSlideAttribute(Stream, BASSAttribute.BASS_ATTRIB_VOL, TargetVolume / 100f, (int)Math.Round(Seconds * 1000f));
|
||||
Bass.BASS_ChannelSetSync(Stream, BASSSync.BASS_SYNC_SLIDE, 0L, _SyncSlideAndPause, IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void FadeAndStop(int Stream, float TargetVolume, float Seconds)
|
||||
{
|
||||
if (_Initialized)
|
||||
@@ -372,6 +390,17 @@ namespace Vocaluxe.Lib.Sound
|
||||
return -1;
|
||||
}
|
||||
|
||||
private void PauseSync(int handle, int Stream, int data, IntPtr user)
|
||||
{
|
||||
if (_Initialized)
|
||||
{
|
||||
if (AlreadyAdded(Stream))
|
||||
{
|
||||
Pause(Stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void EndSync(int handle, int Stream, int data, IntPtr user)
|
||||
{
|
||||
if (_Initialized)
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace Vocaluxe.Lib.Sound
|
||||
private float _targetVolume;
|
||||
private float _startVolume;
|
||||
private bool _closeStreamAfterFade = false;
|
||||
private bool _pauseStreamAfterFade = false;
|
||||
private bool _fading = false;
|
||||
|
||||
public int Handle;
|
||||
@@ -80,6 +81,7 @@ namespace Vocaluxe.Lib.Sound
|
||||
_CurrentTime = Position;
|
||||
_Timer.Start();
|
||||
}
|
||||
_pauseStreamAfterFade = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,6 +238,9 @@ namespace Vocaluxe.Lib.Sound
|
||||
|
||||
if (_closeStreamAfterFade)
|
||||
return false;
|
||||
|
||||
if (_pauseStreamAfterFade)
|
||||
Pause();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -256,6 +261,15 @@ namespace Vocaluxe.Lib.Sound
|
||||
_fadeTimer.Start();
|
||||
}
|
||||
|
||||
public void FadeAndPause(float TargetVolume, float FadeTime)
|
||||
{
|
||||
if (!_loaded || _volumeStream == null)
|
||||
return;
|
||||
|
||||
_pauseStreamAfterFade = true;
|
||||
Fade(TargetVolume, FadeTime);
|
||||
}
|
||||
|
||||
public void FadeAndStop(float TargetVolume, float FadeTime)
|
||||
{
|
||||
if (!_loaded || _volumeStream == null)
|
||||
@@ -526,6 +540,22 @@ namespace Vocaluxe.Lib.Sound
|
||||
}
|
||||
}
|
||||
|
||||
public void FadeAndPause(int Stream, float TargetVolume, float Seconds)
|
||||
{
|
||||
if (_Initialized)
|
||||
{
|
||||
lock (MutexAudioStreams)
|
||||
{
|
||||
if (AlreadyAdded(Stream))
|
||||
{
|
||||
int index = GetStreamIndex(Stream);
|
||||
_Streams[index].FadeAndPause(TargetVolume, Seconds);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void FadeAndStop(int Stream, float TargetVolume, float Seconds)
|
||||
{
|
||||
if (_Initialized)
|
||||
|
||||
@@ -188,6 +188,21 @@ namespace Vocaluxe.Lib.Sound
|
||||
}
|
||||
}
|
||||
|
||||
public void FadeAndPause(int Stream, float TargetVolume, float Seconds)
|
||||
{
|
||||
if (_Initialized)
|
||||
{
|
||||
lock (MutexDecoder)
|
||||
{
|
||||
if (AlreadyAdded(Stream))
|
||||
{
|
||||
_Decoder[GetStreamIndex(Stream)].FadeAndPause(TargetVolume, Seconds);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void FadeAndStop(int Stream, float TargetVolume, float Seconds)
|
||||
{
|
||||
if (_Initialized)
|
||||
@@ -390,6 +405,7 @@ namespace Vocaluxe.Lib.Sound
|
||||
private float _targetVolume = 1f;
|
||||
private float _startVolume = 1f;
|
||||
private bool _closeStreamAfterFade = false;
|
||||
private bool _pauseStreamAfterFade = false;
|
||||
private bool _fading = false;
|
||||
|
||||
|
||||
@@ -528,6 +544,12 @@ namespace Vocaluxe.Lib.Sound
|
||||
_fadeTimer.Start();
|
||||
}
|
||||
|
||||
public void FadeAndPause(float TargetVolume, float FadeTime)
|
||||
{
|
||||
_pauseStreamAfterFade = true;
|
||||
Fade(TargetVolume, FadeTime);
|
||||
}
|
||||
|
||||
public void FadeAndStop(float TargetVolume, float FadeTime, CLOSEPROC close_proc, int StreamID)
|
||||
{
|
||||
_Closeproc = close_proc;
|
||||
@@ -539,6 +561,7 @@ namespace Vocaluxe.Lib.Sound
|
||||
public void Play()
|
||||
{
|
||||
Paused = false;
|
||||
_pauseStreamAfterFade = false;
|
||||
AL.SourcePlay(_source);
|
||||
}
|
||||
|
||||
@@ -756,6 +779,9 @@ namespace Vocaluxe.Lib.Sound
|
||||
|
||||
if (_closeStreamAfterFade)
|
||||
_terminated = true;
|
||||
|
||||
if (_pauseStreamAfterFade)
|
||||
Paused = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,6 +172,21 @@ namespace Vocaluxe.Lib.Sound
|
||||
}
|
||||
}
|
||||
|
||||
public void FadeAndPause(int Stream, float TargetVolume, float Seconds)
|
||||
{
|
||||
if (_Initialized)
|
||||
{
|
||||
lock (MutexDecoder)
|
||||
{
|
||||
if (AlreadyAdded(Stream))
|
||||
{
|
||||
_Decoder[GetStreamIndex(Stream)].FadeAndPause(TargetVolume, Seconds);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void FadeAndStop(int Stream, float TargetVolume, float Seconds)
|
||||
{
|
||||
if (_Initialized)
|
||||
@@ -366,6 +381,7 @@ namespace Vocaluxe.Lib.Sound
|
||||
private float _targetVolume = 1f;
|
||||
private float _startVolume = 1f;
|
||||
private bool _closeStreamAfterFade = false;
|
||||
private bool _pauseStreamAfterFade = false;
|
||||
private bool _fading = false;
|
||||
|
||||
|
||||
@@ -507,6 +523,13 @@ namespace Vocaluxe.Lib.Sound
|
||||
_fadeTimer.Start();
|
||||
}
|
||||
|
||||
public void FadeAndPause(float TargetVolume, float FadeTime)
|
||||
{
|
||||
_pauseStreamAfterFade = true;
|
||||
|
||||
Fade(TargetVolume, FadeTime);
|
||||
}
|
||||
|
||||
public void FadeAndStop(float TargetVolume, float FadeTime, CLOSEPROC close_proc, int StreamID)
|
||||
{
|
||||
_Closeproc = close_proc;
|
||||
@@ -519,6 +542,7 @@ namespace Vocaluxe.Lib.Sound
|
||||
public void Play()
|
||||
{
|
||||
Paused = false;
|
||||
_pauseStreamAfterFade = false;
|
||||
errorCheck("StartStream", PortAudio.Pa_StartStream(_Ptr));
|
||||
}
|
||||
|
||||
@@ -889,6 +913,9 @@ namespace Vocaluxe.Lib.Sound
|
||||
|
||||
if (_closeStreamAfterFade)
|
||||
_terminated = true;
|
||||
|
||||
if (_pauseStreamAfterFade)
|
||||
Paused = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace Vocaluxe.Lib.Sound
|
||||
void Pause(int Stream);
|
||||
void Stop(int Stream);
|
||||
void Fade(int Stream, float TargetVolume, float Seconds);
|
||||
void FadeAndPause(int Stream, float TargetVolume, float Seconds);
|
||||
void FadeAndStop(int Stream, float TargetVolume, float Seconds);
|
||||
void SetStreamVolume(int Stream, float Volume);
|
||||
|
||||
|
||||
@@ -65,6 +65,10 @@ namespace Vocaluxe.Screens
|
||||
CGraphics.FadeTo(EScreens.ScreenSong);
|
||||
break;
|
||||
|
||||
case Keys.T:
|
||||
CGraphics.FadeTo(EScreens.ScreenTest);
|
||||
break;
|
||||
|
||||
case Keys.Enter:
|
||||
if (Buttons[htButtons(ButtonSing)].Selected)
|
||||
CGraphics.FadeTo(EScreens.ScreenSong);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
@@ -14,6 +15,8 @@ namespace Vocaluxe.Screens
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
const int ScreenVersion = 1;
|
||||
|
||||
private int _TestMusic = -1;
|
||||
|
||||
public CScreenTest()
|
||||
{
|
||||
Init();
|
||||
@@ -45,6 +48,18 @@ namespace Vocaluxe.Screens
|
||||
case Keys.Enter:
|
||||
CGraphics.FadeTo(EScreens.ScreenMain);
|
||||
break;
|
||||
|
||||
case Keys.F:
|
||||
FadeAndPause();
|
||||
break;
|
||||
|
||||
case Keys.S:
|
||||
PlayFile();
|
||||
break;
|
||||
|
||||
case Keys.P:
|
||||
PauseFile();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,5 +101,24 @@ namespace Vocaluxe.Screens
|
||||
{
|
||||
return base.Draw();
|
||||
}
|
||||
|
||||
private void PlayFile()
|
||||
{
|
||||
if (_TestMusic == -1)
|
||||
_TestMusic = CSound.Load(Path.Combine(Environment.CurrentDirectory, "Test.mp3"));
|
||||
|
||||
CSound.Play(_TestMusic);
|
||||
CSound.Fade(_TestMusic, 100f, 2f);
|
||||
}
|
||||
|
||||
private void PauseFile()
|
||||
{
|
||||
CSound.Pause(_TestMusic);
|
||||
}
|
||||
|
||||
private void FadeAndPause()
|
||||
{
|
||||
CSound.FadeAndPause(_TestMusic, 0f, 2f);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user