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 diff --git a/Vocaluxe/Lib/Draw/CDirect3D.cs b/Vocaluxe/Lib/Draw/CDirect3D.cs index 10820a50..867a7187 100644 --- a/Vocaluxe/Lib/Draw/CDirect3D.cs +++ b/Vocaluxe/Lib/Draw/CDirect3D.cs @@ -486,7 +486,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; @@ -966,7 +966,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); @@ -1042,7 +1042,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); @@ -1091,7 +1091,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); @@ -1104,6 +1104,23 @@ namespace Vocaluxe.Lib.Draw Texture.height_ratio = Texture.height / CheckForNextPowerOf2(Texture.height); Texture.width_ratio = Texture.width / CheckForNextPowerOf2(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; @@ -1446,7 +1463,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);