This commit is contained in:
Stephan Sundermann committed 2012-02-19 20:49:40 +01:00
commit 486b7235f3
9 files changed
+159

No files matched your search

+5
View File
@@ -101,6 +101,11 @@ namespace Vocaluxe.Base
_Playback.Fade(Stream, TargetVolume, Seconds); _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) public static void FadeAndStop(int Stream, float TargetVolume, float Seconds)
{ {
_Playback.FadeAndStop(Stream, TargetVolume, Seconds); _Playback.FadeAndStop(Stream, TargetVolume, Seconds);
+29
View File
@@ -17,6 +17,7 @@ namespace Vocaluxe.Lib.Sound
private bool _Initialized = false; private bool _Initialized = false;
private List<AudioStreams> _Streams; private List<AudioStreams> _Streams;
private SYNCPROC _SyncSlideAndStop; private SYNCPROC _SyncSlideAndStop;
private SYNCPROC _SyncSlideAndPause;
private Object MutexAudioStreams = new Object(); 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); ok = Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
_Streams = new List<AudioStreams>(); _Streams = new List<AudioStreams>();
_SyncSlideAndStop = new SYNCPROC(EndSync); _SyncSlideAndStop = new SYNCPROC(EndSync);
_SyncSlideAndPause = new SYNCPROC(PauseSync);
} }
catch (Exception) 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) public void FadeAndStop(int Stream, float TargetVolume, float Seconds)
{ {
if (_Initialized) if (_Initialized)
@@ -372,6 +390,17 @@ namespace Vocaluxe.Lib.Sound
return -1; 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) private void EndSync(int handle, int Stream, int data, IntPtr user)
{ {
if (_Initialized) if (_Initialized)
+30
View File
@@ -38,6 +38,7 @@ namespace Vocaluxe.Lib.Sound
private float _targetVolume; private float _targetVolume;
private float _startVolume; private float _startVolume;
private bool _closeStreamAfterFade = false; private bool _closeStreamAfterFade = false;
private bool _pauseStreamAfterFade = false;
private bool _fading = false; private bool _fading = false;
public int Handle; public int Handle;
@@ -80,6 +81,7 @@ namespace Vocaluxe.Lib.Sound
_CurrentTime = Position; _CurrentTime = Position;
_Timer.Start(); _Timer.Start();
} }
_pauseStreamAfterFade = false;
} }
} }
@@ -236,6 +238,9 @@ namespace Vocaluxe.Lib.Sound
if (_closeStreamAfterFade) if (_closeStreamAfterFade)
return false; return false;
if (_pauseStreamAfterFade)
Pause();
} }
return true; return true;
} }
@@ -256,6 +261,15 @@ namespace Vocaluxe.Lib.Sound
_fadeTimer.Start(); _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) public void FadeAndStop(float TargetVolume, float FadeTime)
{ {
if (!_loaded || _volumeStream == null) 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) public void FadeAndStop(int Stream, float TargetVolume, float Seconds)
{ {
if (_Initialized) if (_Initialized)
+27
View File
@@ -189,6 +189,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) public void FadeAndStop(int Stream, float TargetVolume, float Seconds)
{ {
if (_Initialized) if (_Initialized)
@@ -391,6 +406,7 @@ namespace Vocaluxe.Lib.Sound
private float _targetVolume = 1f; private float _targetVolume = 1f;
private float _startVolume = 1f; private float _startVolume = 1f;
private bool _closeStreamAfterFade = false; private bool _closeStreamAfterFade = false;
private bool _pauseStreamAfterFade = false;
private bool _fading = false; private bool _fading = false;
@@ -529,6 +545,12 @@ namespace Vocaluxe.Lib.Sound
_fadeTimer.Start(); _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) public void FadeAndStop(float TargetVolume, float FadeTime, CLOSEPROC close_proc, int StreamID)
{ {
_Closeproc = close_proc; _Closeproc = close_proc;
@@ -540,12 +562,14 @@ namespace Vocaluxe.Lib.Sound
public void Play() public void Play()
{ {
Paused = false; Paused = false;
_pauseStreamAfterFade = false;
AL.SourcePlay(_source); AL.SourcePlay(_source);
} }
public void Stop() public void Stop()
{ {
AL.SourceStop(_source); AL.SourceStop(_source);
Skip(0f);
} }
public bool Loop public bool Loop
@@ -757,6 +781,9 @@ namespace Vocaluxe.Lib.Sound
if (_closeStreamAfterFade) if (_closeStreamAfterFade)
_terminated = true; _terminated = true;
if (_pauseStreamAfterFade)
Paused = true;
} }
} }
} }
+28
View File
@@ -173,6 +173,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) public void FadeAndStop(int Stream, float TargetVolume, float Seconds)
{ {
if (_Initialized) if (_Initialized)
@@ -367,6 +382,7 @@ namespace Vocaluxe.Lib.Sound
private float _targetVolume = 1f; private float _targetVolume = 1f;
private float _startVolume = 1f; private float _startVolume = 1f;
private bool _closeStreamAfterFade = false; private bool _closeStreamAfterFade = false;
private bool _pauseStreamAfterFade = false;
private bool _fading = false; private bool _fading = false;
@@ -508,6 +524,13 @@ namespace Vocaluxe.Lib.Sound
_fadeTimer.Start(); _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) public void FadeAndStop(float TargetVolume, float FadeTime, CLOSEPROC close_proc, int StreamID)
{ {
_Closeproc = close_proc; _Closeproc = close_proc;
@@ -520,12 +543,14 @@ namespace Vocaluxe.Lib.Sound
public void Play() public void Play()
{ {
Paused = false; Paused = false;
_pauseStreamAfterFade = false;
errorCheck("StartStream", PortAudio.Pa_StartStream(_Ptr)); errorCheck("StartStream", PortAudio.Pa_StartStream(_Ptr));
} }
public void Stop() public void Stop()
{ {
errorCheck("StartStream", PortAudio.Pa_StopStream(_Ptr)); errorCheck("StartStream", PortAudio.Pa_StopStream(_Ptr));
Skip(0f);
} }
public bool Loop public bool Loop
@@ -890,6 +915,9 @@ namespace Vocaluxe.Lib.Sound
if (_closeStreamAfterFade) if (_closeStreamAfterFade)
_terminated = true; _terminated = true;
if (_pauseStreamAfterFade)
Paused = true;
} }
} }
} }
+1
View File
@@ -35,6 +35,7 @@ namespace Vocaluxe.Lib.Sound
void Pause(int Stream); void Pause(int Stream);
void Stop(int Stream); void Stop(int Stream);
void Fade(int Stream, float TargetVolume, float Seconds); 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 FadeAndStop(int Stream, float TargetVolume, float Seconds);
void SetStreamVolume(int Stream, float Volume); void SetStreamVolume(int Stream, float Volume);
+1
View File
@@ -12,6 +12,7 @@ using Vocaluxe.Menu;
namespace Vocaluxe namespace Vocaluxe
{ {
// just a small comment for the new develop branch
static class MainProgram static class MainProgram
{ {
static SplashScreen _SplashScreen; static SplashScreen _SplashScreen;
+4
View File
@@ -65,6 +65,10 @@ namespace Vocaluxe.Screens
CGraphics.FadeTo(EScreens.ScreenSong); CGraphics.FadeTo(EScreens.ScreenSong);
break; break;
case Keys.T:
CGraphics.FadeTo(EScreens.ScreenTest);
break;
case Keys.Enter: case Keys.Enter:
if (Buttons[htButtons(ButtonSing)].Selected) if (Buttons[htButtons(ButtonSing)].Selected)
CGraphics.FadeTo(EScreens.ScreenSong); CGraphics.FadeTo(EScreens.ScreenSong);
+34
View File
@@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Text; using System.Text;
using System.Windows.Forms; 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! // Version number for theme files. Increment it, if you've changed something on the theme files!
const int ScreenVersion = 1; const int ScreenVersion = 1;
private int _TestMusic = -1;
public CScreenTest() public CScreenTest()
{ {
Init(); Init();
@@ -45,6 +48,18 @@ namespace Vocaluxe.Screens
case Keys.Enter: case Keys.Enter:
CGraphics.FadeTo(EScreens.ScreenMain); CGraphics.FadeTo(EScreens.ScreenMain);
break; 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(); 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);
}
} }
} }