Merge pull request #213 from lukeIam/karaoke2
Karaoke effect option (gstreamer only)
This commit is contained in:
commit
74c1ea3ad4
17 files changed
+161
-23
No files matched your search
@@ -2,7 +2,7 @@
|
||||
<Screen xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<Informations>
|
||||
<ScreenName>ScreenOptionsSound</ScreenName>
|
||||
<ScreenVersion>3</ScreenVersion>
|
||||
<ScreenVersion>4</ScreenVersion>
|
||||
</Informations>
|
||||
<Backgrounds>
|
||||
<Background Name="Background1">
|
||||
@@ -110,6 +110,20 @@
|
||||
<Style>Bold</Style>
|
||||
<Font>Outline</Font>
|
||||
<Text>TR_SCREENOSOUND_GAMEMUSICVOLUME</Text>
|
||||
</Text>
|
||||
<Text Name="Text7">
|
||||
<X>75</X>
|
||||
<Y>407</Y>
|
||||
<Z>0</Z>
|
||||
<H>27</H>
|
||||
<MaxW>0</MaxW>
|
||||
<Color Name="StaticColor" />
|
||||
<SelColor Name="TextSelColor" />
|
||||
<Align>Left</Align>
|
||||
<ResizeAlign>Center</ResizeAlign>
|
||||
<Style>Bold</Style>
|
||||
<Font>Outline</Font>
|
||||
<Text>TR_SCREENOSOUND_KARAOKEEFFECT</Text>
|
||||
</Text>
|
||||
</Texts>
|
||||
<Buttons>
|
||||
@@ -361,6 +375,48 @@
|
||||
<TextFont>Outline</TextFont>
|
||||
<TextStyle>Bold</TextStyle>
|
||||
<NumVisible>3</NumVisible>
|
||||
</SelectSlide>
|
||||
<SelectSlide Name="SelectSlideKaraokeEffect">
|
||||
<Skin/>
|
||||
<SkinArrowLeft>SelectSlideArrowLeft</SkinArrowLeft>
|
||||
<SkinArrowRight>SelectSlideArrowRight</SkinArrowRight>
|
||||
<SkinSelected>SelectSlide</SkinSelected>
|
||||
<SkinArrowLeftSelected>SelectSlideArrowLeft</SkinArrowLeftSelected>
|
||||
<SkinArrowRightSelected>SelectSlideArrowRight</SkinArrowRightSelected>
|
||||
<Rect>
|
||||
<X>500</X>
|
||||
<Y>400</Y>
|
||||
<W>700</W>
|
||||
<H>50</H>
|
||||
<Z>0</Z>
|
||||
</Rect>
|
||||
<RectArrowLeft>
|
||||
<X>505</X>
|
||||
<Y>405</Y>
|
||||
<W>40</W>
|
||||
<H>40</H>
|
||||
<Z>0</Z>
|
||||
</RectArrowLeft>
|
||||
<RectArrowRight>
|
||||
<X>1170</X>
|
||||
<Y>405</Y>
|
||||
<W>40</W>
|
||||
<H>40</H>
|
||||
<Z>0</Z>
|
||||
</RectArrowRight>
|
||||
<Color Name="SelectSlideColor" />
|
||||
<SelColor Name="SelectSlideSelColor" />
|
||||
<ArrowColor Name="ArrowColor" />
|
||||
<ArrowSelColor Name="ArrowSelColor" />
|
||||
<TextColor Name="TextColor" />
|
||||
<TextSelColor Name="TextSelColor" />
|
||||
<TextH>27</TextH>
|
||||
<TextRelativeX>50</TextRelativeX>
|
||||
<TextRelativeY>0</TextRelativeY>
|
||||
<TextMaxW>500</TextMaxW>
|
||||
<TextFont>Outline</TextFont>
|
||||
<TextStyle>Bold</TextStyle>
|
||||
<NumVisible>2</NumVisible>
|
||||
</SelectSlide>
|
||||
</SelectSlides>
|
||||
<SingNotes />
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
ScreenOptionsSound
|
||||
|
||||
++++++++++
|
||||
Version 4:
|
||||
|
||||
Add:
|
||||
|
||||
<SelectSlideKaraokeEffect>
|
||||
|
||||
and text for the description (Text7)
|
||||
"TR_SCREENOSOUND_KARAOKEEFFECT"
|
||||
|
||||
++++++++++
|
||||
Version 3:
|
||||
|
||||
|
||||
@@ -120,6 +120,8 @@ namespace Vocaluxe.Base
|
||||
[DefaultValue(EOffOn.TR_CONFIG_ON)] public EOffOn BackgroundMusicUseStart;
|
||||
[XmlRanged(0, 100), DefaultValue(50)] public int PreviewMusicVolume;
|
||||
[XmlRanged(0, 100), DefaultValue(80)] public int GameMusicVolume;
|
||||
[DefaultValue(EOffOn.TR_CONFIG_OFF)] public EOffOn KaraokeEffect;
|
||||
[XmlRanged(0, 1), DefaultValue(1.0f)] public float KaraokeEffectLevel;
|
||||
// ReSharper restore MemberHidesStaticFromOuterClass
|
||||
}
|
||||
|
||||
@@ -453,6 +455,10 @@ namespace Vocaluxe.Base
|
||||
return "Preview Volume from 0 to 100";
|
||||
case "GameMusicVolume":
|
||||
return "Game Volume from 0 to 100";
|
||||
case "KaraokeEffect":
|
||||
return "Apply a karaoke effect to song playback (EPlaybackLib.GstreamerSharp only)";
|
||||
case "KaraokeEffectLevel":
|
||||
return "The level of the karaoke effect [0-1] (EPlaybackLib.GstreamerSharp only)";
|
||||
case "Language":
|
||||
return "Game-Language";
|
||||
case "SongFolder":
|
||||
|
||||
@@ -22,6 +22,7 @@ using Vocaluxe.Lib.Sound.Playback.OpenAL;
|
||||
using Vocaluxe.Lib.Sound.Playback.PortAudio;
|
||||
using VocaluxeLib;
|
||||
using System.Threading;
|
||||
using Vocaluxe.Lib.Sound;
|
||||
|
||||
namespace Vocaluxe.Base
|
||||
{
|
||||
@@ -88,9 +89,9 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
|
||||
#region Stream Handling
|
||||
public static int Load(string media, bool loop = false, bool prescan = false)
|
||||
public static int Load(string media, bool loop = false, bool prescan = false, EAudioEffect effekt = EAudioEffect.None)
|
||||
{
|
||||
return _Playback.Load(media, loop, prescan);
|
||||
return _Playback.Load(media, loop, prescan, effekt);
|
||||
}
|
||||
|
||||
public static void Close(int stream)
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Vocaluxe.Lib.Sound
|
||||
{
|
||||
[Flags]
|
||||
public enum EAudioEffect
|
||||
{
|
||||
None = 0,
|
||||
Karaoke = 1
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ namespace Vocaluxe.Lib.Sound.Playback
|
||||
private readonly int _ID;
|
||||
protected readonly string _Medium;
|
||||
protected readonly bool _Loop;
|
||||
protected readonly EAudioEffect _Effect;
|
||||
|
||||
protected ICloseStreamListener _CloseStreamListener;
|
||||
|
||||
@@ -48,11 +49,12 @@ namespace Vocaluxe.Lib.Sound.Playback
|
||||
public abstract bool IsPaused { get; set; }
|
||||
public abstract bool IsFinished { get; }
|
||||
|
||||
protected CAudioStreamBase(int id, string medium, bool loop)
|
||||
protected CAudioStreamBase(int id, string medium, bool loop, EAudioEffect effect = EAudioEffect.None)
|
||||
{
|
||||
_ID = id;
|
||||
_Medium = medium;
|
||||
_Loop = loop;
|
||||
_Effect = effect;
|
||||
}
|
||||
|
||||
~CAudioStreamBase()
|
||||
|
||||
@@ -113,13 +113,13 @@ namespace Vocaluxe.Lib.Sound.Playback
|
||||
|
||||
#region Stream Handling
|
||||
//Factory method to get a stream instance
|
||||
protected abstract IAudioStream _CreateStream(int id, string media, bool loop);
|
||||
protected abstract IAudioStream _CreateStream(int id, string media, bool loop, EAudioEffect effect = EAudioEffect.None);
|
||||
|
||||
public int Load(string medium, bool loop = false, bool prescan = false)
|
||||
public int Load(string medium, bool loop = false, bool prescan = false, EAudioEffect effect = EAudioEffect.None)
|
||||
{
|
||||
if (!_Initialized)
|
||||
return -1;
|
||||
IAudioStream stream = _CreateStream(_NextID++, medium, loop);
|
||||
IAudioStream stream = _CreateStream(_NextID++, medium, loop, effect);
|
||||
|
||||
if (stream.Open(prescan))
|
||||
{
|
||||
|
||||
@@ -72,9 +72,9 @@ namespace Vocaluxe.Lib.Sound.Playback.GstreamerSharp
|
||||
Application.Deinit();
|
||||
}
|
||||
|
||||
protected override IAudioStream _CreateStream(int id, string media, bool loop)
|
||||
protected override IAudioStream _CreateStream(int id, string media, bool loop, EAudioEffect effect = EAudioEffect.None)
|
||||
{
|
||||
return new CGstreamerSharpAudioStream(id, media, loop);
|
||||
return new CGstreamerSharpAudioStream(id, media, loop, effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ using System;
|
||||
using GLib;
|
||||
using Gst;
|
||||
using Vocaluxe.Base;
|
||||
using VocaluxeLib;
|
||||
|
||||
namespace Vocaluxe.Lib.Sound.Playback.GstreamerSharp
|
||||
{
|
||||
@@ -101,7 +102,7 @@ namespace Vocaluxe.Lib.Sound.Playback.GstreamerSharp
|
||||
}
|
||||
}
|
||||
|
||||
public CGstreamerSharpAudioStream(int id, string medium, bool loop) : base(id, medium, loop) {}
|
||||
public CGstreamerSharpAudioStream(int id, string medium, bool loop, EAudioEffect effect = EAudioEffect.None) : base(id, medium, loop, effect) {}
|
||||
|
||||
public override bool Open(bool prescan)
|
||||
{
|
||||
@@ -123,9 +124,29 @@ namespace Vocaluxe.Lib.Sound.Playback.GstreamerSharp
|
||||
}
|
||||
|
||||
var audioSinkBin = new Bin("Audiosink");
|
||||
audioSinkBin.Add(convert);
|
||||
audioSinkBin.Add(audiosink);
|
||||
convert.Link(audiosink);
|
||||
Element audiokaraoke = null;
|
||||
if (_Effect.HasFlag(EAudioEffect.Karaoke))
|
||||
{
|
||||
audiokaraoke = ElementFactory.Make("audiokaraoke", "karaoke");
|
||||
audioSinkBin.Add(audiokaraoke);
|
||||
audioSinkBin.Add(convert);
|
||||
audioSinkBin.Add(audiosink);
|
||||
|
||||
audiokaraoke.Link(audiosink);
|
||||
audiokaraoke["level"] = CConfig.Config.Sound.KaraokeEffectLevel;
|
||||
audiokaraoke["mono-level"] = CConfig.Config.Sound.KaraokeEffectLevel;
|
||||
|
||||
convert.Link(audiokaraoke);
|
||||
}
|
||||
else
|
||||
{
|
||||
audioSinkBin.Add(convert);
|
||||
audioSinkBin.Add(audiosink);
|
||||
convert.Link(audiosink);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Pad pad = convert.GetStaticPad("sink");
|
||||
GhostPad ghostpad = new GhostPad("sink", pad);
|
||||
|
||||
@@ -135,6 +156,10 @@ namespace Vocaluxe.Lib.Sound.Playback.GstreamerSharp
|
||||
convert.Dispose();
|
||||
audiosink.Dispose();
|
||||
audioSinkBin.Dispose();
|
||||
if (audiokaraoke != null)
|
||||
{
|
||||
audiokaraoke.Dispose();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -145,6 +170,10 @@ namespace Vocaluxe.Lib.Sound.Playback.GstreamerSharp
|
||||
audiosink.Dispose();
|
||||
audioSinkBin.Dispose();
|
||||
ghostpad.Dispose();
|
||||
if (audiokaraoke != null)
|
||||
{
|
||||
audiokaraoke.Dispose();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (!audioSinkBin.AddPad(ghostpad))
|
||||
@@ -154,6 +183,10 @@ namespace Vocaluxe.Lib.Sound.Playback.GstreamerSharp
|
||||
audiosink.Dispose();
|
||||
audioSinkBin.Dispose();
|
||||
ghostpad.Dispose();
|
||||
if (audiokaraoke != null)
|
||||
{
|
||||
audiokaraoke.Dispose();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -165,6 +198,10 @@ namespace Vocaluxe.Lib.Sound.Playback.GstreamerSharp
|
||||
audiosink.Dispose();
|
||||
audioSinkBin.Dispose();
|
||||
ghostpad.Dispose();
|
||||
if (audiokaraoke != null)
|
||||
{
|
||||
audiokaraoke.Dispose();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
_Element["audio-sink"] = audioSinkBin;
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Vocaluxe.Lib.Sound.Playback
|
||||
void CloseAll();
|
||||
|
||||
#region stream Handling
|
||||
int Load(string medium, bool loop = false, bool prescan = false);
|
||||
int Load(string medium, bool loop = false, bool prescan = false, EAudioEffect effekt= EAudioEffect.None);
|
||||
void Close(int streamID);
|
||||
|
||||
void Play(int streamID);
|
||||
|
||||
@@ -44,9 +44,9 @@ namespace Vocaluxe.Lib.Sound.Playback.OpenAL
|
||||
_Context = null;
|
||||
}
|
||||
|
||||
protected override IAudioStream _CreateStream(int id, string media, bool loop)
|
||||
protected override IAudioStream _CreateStream(int id, string media, bool loop, EAudioEffect effect = EAudioEffect.None)
|
||||
{
|
||||
return new COpenAlStream(id, media, loop);
|
||||
return new COpenAlStream(id, media, loop, effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,7 +122,7 @@ namespace Vocaluxe.Lib.Sound.Playback.OpenAL
|
||||
}
|
||||
}
|
||||
|
||||
public COpenAlStream(int id, string medium, bool loop) : base(id, medium, loop) {}
|
||||
public COpenAlStream(int id, string medium, bool loop, EAudioEffect effect = EAudioEffect.None) : base(id, medium, loop, effect) {}
|
||||
|
||||
protected override void _Dispose(bool disposing)
|
||||
{
|
||||
|
||||
@@ -29,9 +29,9 @@ namespace Vocaluxe.Lib.Sound.Playback.PortAudio
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override IAudioStream _CreateStream(int id, string media, bool loop)
|
||||
protected override IAudioStream _CreateStream(int id, string media, bool loop, EAudioEffect effect = EAudioEffect.None)
|
||||
{
|
||||
return new CPortAudioStream(id, media, loop);
|
||||
return new CPortAudioStream(id, media, loop, effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,7 +131,7 @@ namespace Vocaluxe.Lib.Sound.Playback.PortAudio
|
||||
}
|
||||
}
|
||||
|
||||
public CPortAudioStream(int id, string medium, bool loop) : base(id, medium, loop) {}
|
||||
public CPortAudioStream(int id, string medium, bool loop, EAudioEffect effect = EAudioEffect.None) : base(id, medium, loop, effect) {}
|
||||
|
||||
public override bool Open(bool prescan)
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Vocaluxe.Screens
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
{
|
||||
get { return 3; }
|
||||
get { return 4; }
|
||||
}
|
||||
|
||||
private const string _SelectSlideBackgroundMusic = "SelectSlideBackgroundMusic";
|
||||
@@ -35,6 +35,7 @@ namespace Vocaluxe.Screens
|
||||
private const string _SelectSlideBackgroundMusicSource = "SelectSlideBackgroundMusicSource";
|
||||
private const string _SelectSlidePreviewMusicVolume = "SelectSlidePreviewMusicVolume";
|
||||
private const string _SelectSlideGameMusicVolume = "SelectSlideGameMusicVolume";
|
||||
private const string _SelectSlideKaraokeEffect = "SelectSlideKaraokeEffect";
|
||||
|
||||
private const string _ButtonExit = "ButtonExit";
|
||||
|
||||
@@ -46,7 +47,7 @@ namespace Vocaluxe.Screens
|
||||
|
||||
_ThemeButtons = new string[] {_ButtonExit};
|
||||
_ThemeSelectSlides = new string[]
|
||||
{_SelectSlideBackgroundMusic, _SelectSlideBackgroundMusicVolume, _SelectSlideBackgroundMusicSource, _SelectSlidePreviewMusicVolume, _SelectSlideGameMusicVolume};
|
||||
{_SelectSlideBackgroundMusic, _SelectSlideBackgroundMusicVolume, _SelectSlideBackgroundMusicSource, _SelectSlidePreviewMusicVolume, _SelectSlideGameMusicVolume, _SelectSlideKaraokeEffect};
|
||||
}
|
||||
|
||||
public override void LoadTheme(string xmlPath)
|
||||
@@ -64,6 +65,11 @@ namespace Vocaluxe.Screens
|
||||
_SelectSlides[_SelectSlideGameMusicVolume].AddValues(new string[]
|
||||
{"0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100"});
|
||||
_SelectSlides[_SelectSlideGameMusicVolume].Selection = CConfig.GameMusicVolume / 5;
|
||||
if (CConfig.Config.Sound.PlayBackLib == EPlaybackLib.GstreamerSharp)
|
||||
{
|
||||
_SelectSlides[_SelectSlideKaraokeEffect].SetValues<EOffOn>((int)CConfig.Config.Sound.KaraokeEffect);
|
||||
_SelectSlides[_SelectSlideBackgroundMusicSource].Selection = (int)CConfig.Config.Sound.KaraokeEffect;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HandleInput(SKeyEvent keyEvent)
|
||||
@@ -147,6 +153,10 @@ namespace Vocaluxe.Screens
|
||||
CConfig.Config.Sound.BackgroundMusic = (EBackgroundMusicOffOn)_SelectSlides[_SelectSlideBackgroundMusic].Selection;
|
||||
CConfig.Config.Sound.BackgroundMusicSource = (EBackgroundMusicSource)_SelectSlides[_SelectSlideBackgroundMusicSource].Selection;
|
||||
CConfig.BackgroundMusicVolume = _SelectSlides[_SelectSlideBackgroundMusicVolume].Selection * 5;
|
||||
if (CConfig.Config.Sound.PlayBackLib == EPlaybackLib.GstreamerSharp)
|
||||
{
|
||||
CConfig.Config.Sound.KaraokeEffect = (EOffOn)_SelectSlides[_SelectSlideKaraokeEffect].Selection;
|
||||
}
|
||||
CConfig.SaveConfig();
|
||||
|
||||
CBackgroundMusic.SetMusicSource(CConfig.Config.Sound.BackgroundMusicSource);
|
||||
|
||||
@@ -24,6 +24,7 @@ using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using Vocaluxe.Base;
|
||||
using Vocaluxe.Base.Fonts;
|
||||
using Vocaluxe.Lib.Sound;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Draw;
|
||||
using VocaluxeLib.Menu;
|
||||
@@ -525,7 +526,7 @@ namespace Vocaluxe.Screens
|
||||
songname += " (" + CGame.RoundNr + "/" + rounds + ")";
|
||||
_Texts[_TextSongName].Text = songname;
|
||||
|
||||
_CurrentStream = CSound.Load(song.GetMP3(), false, true);
|
||||
_CurrentStream = CSound.Load(song.GetMP3(), false, true, CConfig.Config.Sound.KaraokeEffect == EOffOn.TR_CONFIG_ON ? EAudioEffect.Karaoke : EAudioEffect.None);
|
||||
CSound.SetStreamVolume(_CurrentStream, 100);
|
||||
CSound.SetPosition(_CurrentStream, song.Start);
|
||||
_CurrentTime = song.Start;
|
||||
|
||||
@@ -185,6 +185,7 @@
|
||||
<Compile Include="Lib\Draw\CTextureBase.cs" />
|
||||
<Compile Include="Lib\Draw\CTextureProvider.cs" />
|
||||
<Compile Include="Lib\Input\CGamePad.cs" />
|
||||
<Compile Include="Lib\Sound\EAudioEffect.cs" />
|
||||
<Compile Include="Lib\Sound\Playback\CAudioStreamBase.cs" />
|
||||
<Compile Include="Lib\Sound\Playback\CPlaybackBase.cs" />
|
||||
<Compile Include="Lib\Sound\Playback\CRingBuffer.cs" />
|
||||
|
||||
Reference in new issue
Block a user