Merge pull request #6 from xDarkice/master

Merged develop and bgmusic branch and some minor fixes
This commit is contained in:
Alexander Eckart committed 2012-02-19 13:26:54 -08:00
commit 683ea3caa4
10 files changed
+163 -4

No files matched your search

+3 -3
View File
@@ -17,7 +17,7 @@ namespace Vocaluxe.Base
private static bool _Fading;
private static Stopwatch _FadeTimer = new Stopwatch();
public static void init()
public static void Init()
{
List<string> files = new List<string>();
files.AddRange(Helper.ListFiles(CSettings.sFolderBackgroundMusic, "*.mp3", true, true));
@@ -60,7 +60,7 @@ namespace Vocaluxe.Base
public static void Pause()
{
if (_BackgroundMusicStreams.Count > 0)
CSound.Pause(_BackgroundMusicStreams[_CurrentStreamListIndex]);
CSound.FadeAndPause(_BackgroundMusicStreams[_CurrentStreamListIndex], 0, CConfig.FadeTime);
}
public static void Update()
@@ -85,7 +85,7 @@ namespace Vocaluxe.Base
}
else
_CurrentMusicStream = _BackgroundMusicStreams[_CurrentStreamListIndex];
CSound.SetPosition(_CurrentStreamListIndex, 0);
CSound.SetPosition(_CurrentMusicStream, 0);
Play();
_Fading = true;
}
+5
View File
@@ -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);
+29
View File
@@ -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)
+30
View File
@@ -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)
+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)
{
if (_Initialized)
@@ -391,6 +406,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;
@@ -529,6 +545,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;
@@ -540,12 +562,14 @@ namespace Vocaluxe.Lib.Sound
public void Play()
{
Paused = false;
_pauseStreamAfterFade = false;
AL.SourcePlay(_source);
}
public void Stop()
{
AL.SourceStop(_source);
Skip(0f);
}
public bool Loop
@@ -757,6 +781,9 @@ namespace Vocaluxe.Lib.Sound
if (_closeStreamAfterFade)
_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)
{
if (_Initialized)
@@ -367,6 +382,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;
@@ -508,6 +524,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;
@@ -520,12 +543,14 @@ namespace Vocaluxe.Lib.Sound
public void Play()
{
Paused = false;
_pauseStreamAfterFade = false;
errorCheck("StartStream", PortAudio.Pa_StartStream(_Ptr));
}
public void Stop()
{
errorCheck("StartStream", PortAudio.Pa_StopStream(_Ptr));
Skip(0f);
}
public bool Loop
@@ -890,6 +915,9 @@ namespace Vocaluxe.Lib.Sound
if (_closeStreamAfterFade)
_terminated = true;
if (_pauseStreamAfterFade)
Paused = true;
}
}
}
+1
View File
@@ -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);
+2 -1
View File
@@ -12,6 +12,7 @@ using Vocaluxe.Menu;
namespace Vocaluxe
{
// just a small comment for the new develop branch
static class MainProgram
{
static SplashScreen _SplashScreen;
@@ -83,7 +84,7 @@ namespace Vocaluxe
// Init Background Music
CLog.StartBenchmark(0, "Init Background Music");
CBackgroundMusic.init();
CBackgroundMusic.Init();
CLog.StopBenchmark(0, "Init Background Music");
// Init Profiles
+4
View File
@@ -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);
+34
View File
@@ -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);
}
}
}