From e8103dd80ecb31660086b1228be1178abe742a78 Mon Sep 17 00:00:00 2001 From: Stephan Sundermann Date: Sun, 13 May 2012 17:37:32 +0200 Subject: [PATCH 1/2] Added alternative method to update a texture, for now we just stick with the old one Changed lockflags to discard old data to improve performance --- Vocaluxe/Lib/Draw/CDirect3D.cs | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/Vocaluxe/Lib/Draw/CDirect3D.cs b/Vocaluxe/Lib/Draw/CDirect3D.cs index 3141d237..7207a945 100644 --- a/Vocaluxe/Lib/Draw/CDirect3D.cs +++ b/Vocaluxe/Lib/Draw/CDirect3D.cs @@ -477,7 +477,7 @@ namespace Vocaluxe.Lib.Draw _IndexBuffer = new IndexBuffer(_Device, 6 * sizeof(Int16), Usage.WriteOnly, Pool.Managed, true); - DataStream stream = _IndexBuffer.Lock(0, 0, LockFlags.None); + DataStream stream = _IndexBuffer.Lock(0, 0, LockFlags.Discard); stream.WriteRange(indices); _IndexBuffer.Unlock(); _Device.Indices = _IndexBuffer; @@ -944,7 +944,7 @@ namespace Vocaluxe.Lib.Draw //because a copy of the texture is hold in the Ram Texture t = new Texture(_Device, (int)texture.w2, (int)texture.h2, 0, Usage.AutoGenerateMipMap, Format.A8R8G8B8, Pool.Managed); //Lock the texture and fill it with the data - DataRectangle rect = t.LockRectangle(0, LockFlags.None); + DataRectangle rect = t.LockRectangle(0, LockFlags.Discard); for (int i = 0; i < Data.Length; ) { rect.Data.Write(Data, i, 4 * bmp2.Width); @@ -1020,7 +1020,7 @@ namespace Vocaluxe.Lib.Draw texture.height_ratio = texture.height / texture.h2; Texture t = new Texture(_Device, (int)texture.w2, (int)texture.h2, 0, Usage.AutoGenerateMipMap, Format.A8R8G8B8, Pool.Managed); - DataRectangle rect = t.LockRectangle(0, LockFlags.None); + DataRectangle rect = t.LockRectangle(0, LockFlags.Discard); for (int i = 0; i < Data.Length; ) { rect.Data.Write(Data, i, 4 * W); @@ -1069,7 +1069,7 @@ namespace Vocaluxe.Lib.Draw { if ((Texture.index >= 0) && (_Textures.Count > 0) && _TextureExists(ref Texture)) { - DataRectangle rect = _D3DTextures[Texture.index].LockRectangle(0, LockFlags.None); + DataRectangle rect = _D3DTextures[Texture.index].LockRectangle(0, LockFlags.Discard); for (int i = 0; i < Data.Length; ) { rect.Data.Write(Data, i, 4 * (int)Texture.width); @@ -1082,6 +1082,23 @@ namespace Vocaluxe.Lib.Draw Texture.height_ratio = Texture.height / NextPowerOfTwo(Texture.height); Texture.width_ratio = Texture.width / NextPowerOfTwo(Texture.width); return true; + + /*Surface s = _D3DTextures[Texture.index].GetSurfaceLevel(0); + DataRectangle d = s.LockRectangle(LockFlags.Discard); + + for (int i = 0; i < Data.Length; ) + { + d.Data.Write(Data, i, 4 * (int)Texture.width); + i += 4 * (int)Texture.width; + d.Data.Position = d.Data.Position - 4 * (int)Texture.width; + d.Data.Position += d.Pitch; + } + + Texture.height_ratio = Texture.height / NextPowerOfTwo(Texture.height); + Texture.width_ratio = Texture.width / NextPowerOfTwo(Texture.width); + + s.UnlockRectangle(); + return true; */ } else return false; @@ -1424,7 +1441,7 @@ namespace Vocaluxe.Lib.Draw texture.height_ratio = texture.height / texture.h2; Texture t = new Texture(_Device, (int)texture.w2, (int)texture.h2, 0, Usage.AutoGenerateMipMap, Format.A8R8G8B8, Pool.Managed); - DataRectangle rect = t.LockRectangle(0, LockFlags.None); + DataRectangle rect = t.LockRectangle(0, LockFlags.Discard); for (int i = 0; i < q.data.Length; ) { rect.Data.Write(q.data, i, 4 * q.width); From e62479249030d0e146224f57684200a7f869de98 Mon Sep 17 00:00:00 2001 From: Stephan Sundermann Date: Tue, 10 Jul 2012 17:52:18 +0200 Subject: [PATCH 2/2] Background music is now using #Start and #End tags, if found --- Vocaluxe/Base/CBackgroundMusic.cs | 34 ++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/Vocaluxe/Base/CBackgroundMusic.cs b/Vocaluxe/Base/CBackgroundMusic.cs index e475081c..17657e6a 100644 --- a/Vocaluxe/Base/CBackgroundMusic.cs +++ b/Vocaluxe/Base/CBackgroundMusic.cs @@ -217,7 +217,12 @@ namespace Vocaluxe.Base { if (_AllFileNames.Count > 0 && _CurrentMusicStream != -1) { - float timeToPlay = CSound.GetLength(_CurrentMusicStream) - CSound.GetPosition(_CurrentMusicStream); + float timeToPlay; + if(_CurrentPlaylistElement.Finish == 0f) //No End-Tag defined + timeToPlay = CSound.GetLength(_CurrentMusicStream) - CSound.GetPosition(_CurrentMusicStream); + else //End-Tag found + timeToPlay = _CurrentPlaylistElement.Finish - CSound.GetPosition(_CurrentMusicStream); + bool finished = CSound.IsFinished(_CurrentMusicStream); if (_Playing && (timeToPlay <= CSettings.BackgroundMusicFadeTime || finished)) Next(); @@ -248,6 +253,11 @@ namespace Vocaluxe.Base _CurrentPlaylistElement = _PreviousFileNames[_PreviousMusicIndex]; } _CurrentMusicStream = CSound.Load(_CurrentPlaylistElement.MusicFilePath); + + //Seek to #Start-Tag, if found + if (_CurrentPlaylistElement.Start != 0f) + CSound.SetPosition(_CurrentMusicStream, _CurrentPlaylistElement.Start); + if (_VideoEnabled) LoadVideo(); CSound.SetStreamVolume(_CurrentMusicStream, 0f); @@ -524,6 +534,28 @@ class PlaylistElement } } + public float Start + { + get + { + if (_Song != null) + return _Song.Start; + + return 0f; + } + } + + public float Finish + { + get + { + if (_Song != null) + return _Song.Finish; + + return 0f; + } + } + public STexture Cover { get