mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-10 19:55:09 +00:00
Merge pull request #59 from minenice55/improved-multisound
extend multisound with pitch, volume, looping, offset in seconds
This commit is contained in:
commit
7444165b08
3 changed files with 23 additions and 9 deletions
|
@ -234,6 +234,12 @@ namespace HeavenStudio
|
||||||
return secPerBeat * beat;
|
return secPerBeat * beat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// convert real seconds to beats
|
||||||
|
public float GetRestFromRealTime(float seconds)
|
||||||
|
{
|
||||||
|
return seconds/secPerBeat;
|
||||||
|
}
|
||||||
|
|
||||||
public void SetBpm(float bpm)
|
public void SetBpm(float bpm)
|
||||||
{
|
{
|
||||||
this.songBpm = bpm;
|
this.songBpm = bpm;
|
||||||
|
|
|
@ -306,8 +306,8 @@ namespace HeavenStudio.Games
|
||||||
if (!noSound)
|
if (!noSound)
|
||||||
MultiSound.Play(new MultiSound.Sound[] {
|
MultiSound.Play(new MultiSound.Sound[] {
|
||||||
new MultiSound.Sound("fanClub/arisa_ka_jp", beat),
|
new MultiSound.Sound("fanClub/arisa_ka_jp", beat),
|
||||||
new MultiSound.Sound("fanClub/arisa_mo_jp", beat + 0.5f),
|
new MultiSound.Sound("fanClub/arisa_mo_jp", beat + 0.5f, offset: 0.07407407f),
|
||||||
new MultiSound.Sound("fanClub/arisa_ne_jp", beat + 1f),
|
new MultiSound.Sound("fanClub/arisa_ne_jp", beat + 1f, offset: 0.07407407f),
|
||||||
});
|
});
|
||||||
|
|
||||||
responseToggle = true;
|
responseToggle = true;
|
||||||
|
@ -355,8 +355,8 @@ namespace HeavenStudio.Games
|
||||||
if (noSound) return;
|
if (noSound) return;
|
||||||
MultiSound.Play(new MultiSound.Sound[] {
|
MultiSound.Play(new MultiSound.Sound[] {
|
||||||
new MultiSound.Sound("fanClub/arisa_ka_jp", beat),
|
new MultiSound.Sound("fanClub/arisa_ka_jp", beat),
|
||||||
new MultiSound.Sound("fanClub/arisa_mo_jp", beat + 0.5f),
|
new MultiSound.Sound("fanClub/arisa_mo_jp", beat + 0.5f, offset: 0.07407407f),
|
||||||
new MultiSound.Sound("fanClub/arisa_ne_jp", beat + 1f),
|
new MultiSound.Sound("fanClub/arisa_ne_jp", beat + 1f, offset: 0.07407407f),
|
||||||
}, forcePlay:true);
|
}, forcePlay:true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,19 @@ namespace HeavenStudio.Util
|
||||||
{
|
{
|
||||||
public string name { get; set; }
|
public string name { get; set; }
|
||||||
public float beat { get; set; }
|
public float beat { get; set; }
|
||||||
|
public float pitch { get; set; }
|
||||||
|
public float volume { get; set; }
|
||||||
|
public bool looping { get; set; }
|
||||||
|
public float offset { get; set; }
|
||||||
|
|
||||||
public Sound(string name, float beat)
|
public Sound(string name, float beat, float pitch = 1f, float volume = 1f, bool looping = false, float offset = 0f)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.beat = beat;
|
this.beat = beat;
|
||||||
|
this.pitch = pitch;
|
||||||
|
this.volume = volume;
|
||||||
|
this.looping = looping;
|
||||||
|
this.offset = offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,18 +55,18 @@ namespace HeavenStudio.Util
|
||||||
|
|
||||||
for (int i = 0; i < sounds.Count; i++)
|
for (int i = 0; i < sounds.Count; i++)
|
||||||
{
|
{
|
||||||
if (songPositionInBeats >= sounds[i].beat && index == i)
|
if (songPositionInBeats >= sounds[i].beat - Conductor.instance.GetRestFromRealTime(sounds[i].offset) && index == i)
|
||||||
{
|
{
|
||||||
if (game)
|
if (game)
|
||||||
Jukebox.PlayOneShotGame(sounds[i].name, forcePlay:forcePlay);
|
Jukebox.PlayOneShotGame(sounds[i].name, sounds[i].beat - Conductor.instance.GetRestFromRealTime(sounds[i].offset), sounds[i].pitch, sounds[i].volume, sounds[i].looping, forcePlay);
|
||||||
else
|
else
|
||||||
Jukebox.PlayOneShot(sounds[i].name);
|
Jukebox.PlayOneShot(sounds[i].name, sounds[i].beat - Conductor.instance.GetRestFromRealTime(sounds[i].offset), sounds[i].pitch, sounds[i].volume, sounds[i].looping);
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (songPositionInBeats >= (sounds[sounds.Count - 1].beat))
|
if (songPositionInBeats >= (sounds[sounds.Count - 1].beat - Conductor.instance.GetRestFromRealTime(sounds[sounds.Count - 1].offset)))
|
||||||
{
|
{
|
||||||
Delete();
|
Delete();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue