mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-13 08:57:39 +02:00
Improve note parameters (#798)
* Add note parameter * Increase max semitones * Add previewing sounds for notes * Add note preview toggle setting * Fix Launch Party starting note * Fix preview sound pooling + add BTS preview sound * Add previewing note when slider handle is clicked
This commit is contained in:

committed by
minenice55

parent
194b4b6e04
commit
35b1120d01
@ -22,7 +22,29 @@ namespace HeavenStudio
|
||||
this.max = max;
|
||||
}
|
||||
}
|
||||
|
||||
public struct Note
|
||||
{
|
||||
public static int maxSemitones = 36;
|
||||
public int min;
|
||||
public int val;
|
||||
public int max;
|
||||
|
||||
public int sampleNote;
|
||||
public int sampleOctave;
|
||||
public string sampleName;
|
||||
|
||||
public Note(int min, int max, int val = 0, int sampleNote = 0, int sampleOctave = 0, string sampleName = "")
|
||||
{
|
||||
this.min = min;
|
||||
this.val = val;
|
||||
this.max = max;
|
||||
this.sampleNote = sampleNote;
|
||||
this.sampleOctave = sampleOctave;
|
||||
this.sampleName = sampleName;
|
||||
}
|
||||
}
|
||||
|
||||
public struct Float
|
||||
{
|
||||
public float min;
|
||||
|
@ -24,6 +24,7 @@ namespace HeavenStudio.Util
|
||||
private AudioSource audioSource;
|
||||
private Conductor cond;
|
||||
|
||||
public bool ignoreConductorPause = false;
|
||||
|
||||
private double startTime;
|
||||
|
||||
@ -114,7 +115,7 @@ namespace HeavenStudio.Util
|
||||
double dspTime = AudioSettings.dspTime;
|
||||
if (!(available || played))
|
||||
{
|
||||
if (!(cond.isPlaying || cond.isPaused))
|
||||
if (!ignoreConductorPause && !(cond.isPlaying || cond.isPaused))
|
||||
{
|
||||
GameManager.instance.SoundObjects.Release(this);
|
||||
return;
|
||||
@ -171,7 +172,7 @@ namespace HeavenStudio.Util
|
||||
|
||||
if (played)
|
||||
{
|
||||
if (!(cond.isPlaying || cond.isPaused))
|
||||
if (!ignoreConductorPause && !(cond.isPlaying || cond.isPaused))
|
||||
{
|
||||
GameManager.instance.SoundObjects.Release(this);
|
||||
return;
|
||||
@ -182,7 +183,7 @@ namespace HeavenStudio.Util
|
||||
return;
|
||||
}
|
||||
|
||||
if (cond.isPaused || cond.SongPitch == 0)
|
||||
if ((!ignoreConductorPause && cond.isPaused) || cond.SongPitch == 0)
|
||||
{
|
||||
if (!paused)
|
||||
{
|
||||
@ -233,8 +234,13 @@ namespace HeavenStudio.Util
|
||||
audioSource.UnPause();
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
public void Stop(bool releaseToPool = false)
|
||||
{
|
||||
if(releaseToPool && audioSource.isPlaying)
|
||||
{
|
||||
GameManager.instance.SoundObjects.Release(this);
|
||||
}
|
||||
|
||||
available = true;
|
||||
played = false;
|
||||
paused = false;
|
||||
@ -246,6 +252,7 @@ namespace HeavenStudio.Util
|
||||
loopEndBeat = -1;
|
||||
loopDone = false;
|
||||
startTime = 0;
|
||||
ignoreConductorPause = false;
|
||||
|
||||
audioSource.loop = false;
|
||||
audioSource.Stop();
|
||||
|
@ -284,7 +284,7 @@ namespace HeavenStudio.Util
|
||||
/// Unpitched, non-scheduled, non-looping sounds are played using a global One-Shot audio source that doesn't create a Sound object.
|
||||
/// Looped sounds return their created Sound object so they can be canceled after creation.
|
||||
/// </summary>
|
||||
public static Sound PlayOneShot(string name, double beat = -1, float pitch = 1f, float volume = 1f, bool looping = false, string game = null, double offset = 0f)
|
||||
public static Sound PlayOneShot(string name, double beat = -1, float pitch = 1f, float volume = 1f, bool looping = false, string game = null, double offset = 0f, bool ignoreConductorPause = false)
|
||||
{
|
||||
AudioClip clip = null;
|
||||
string soundName = name.Split('/')[^1];
|
||||
@ -334,6 +334,7 @@ namespace HeavenStudio.Util
|
||||
snd.volume = volume;
|
||||
snd.looping = looping;
|
||||
snd.offset = offset;
|
||||
snd.ignoreConductorPause = ignoreConductorPause;
|
||||
snd.Play();
|
||||
|
||||
return snd;
|
||||
@ -355,7 +356,7 @@ namespace HeavenStudio.Util
|
||||
/// <summary>
|
||||
/// Schedules a sound to be played at a specific time in seconds.
|
||||
/// </summary>
|
||||
public static Sound PlayOneShotScheduled(string name, double targetTime, float pitch = 1f, float volume = 1f, bool looping = false, string game = null)
|
||||
public static Sound PlayOneShotScheduled(string name, double targetTime, float pitch = 1f, float volume = 1f, bool looping = false, string game = null, bool ignoreConductorPause = false)
|
||||
{
|
||||
Sound snd = GetAvailableScheduledSound();
|
||||
AudioClip clip = null;
|
||||
@ -405,6 +406,7 @@ namespace HeavenStudio.Util
|
||||
|
||||
snd.scheduled = true;
|
||||
snd.scheduledTime = targetTime;
|
||||
snd.ignoreConductorPause = ignoreConductorPause;
|
||||
snd.Play();
|
||||
|
||||
return snd;
|
||||
@ -415,13 +417,13 @@ namespace HeavenStudio.Util
|
||||
/// Unpitched, non-scheduled, non-looping sounds are played using a global One-Shot audio source that doesn't create a Sound object.
|
||||
/// Looped sounds return their created Sound object so they can be canceled after creation.
|
||||
/// </summary>
|
||||
public static Sound PlayOneShotGame(string name, double beat = -1, float pitch = 1f, float volume = 1f, bool looping = false, bool forcePlay = false, double offset = 0f)
|
||||
public static Sound PlayOneShotGame(string name, double beat = -1, float pitch = 1f, float volume = 1f, bool looping = false, bool forcePlay = false, double offset = 0f, bool ignoreConductorPause = false)
|
||||
{
|
||||
string gameName = name.Split('/')[0];
|
||||
var inf = GameManager.instance.GetGameInfo(gameName);
|
||||
if (GameManager.instance.currentGame == gameName || forcePlay)
|
||||
{
|
||||
return PlayOneShot($"games/{name}", beat, pitch, volume, looping, inf.usesAssetBundle ? gameName : null, offset);
|
||||
return PlayOneShot($"games/{name}", beat, pitch, volume, looping, inf.usesAssetBundle ? gameName : null, offset, ignoreConductorPause);
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -431,13 +433,13 @@ namespace HeavenStudio.Util
|
||||
/// Schedules a sound to be played at a specific time in seconds.
|
||||
/// Audio clip is fetched from minigame resources
|
||||
/// </summary>
|
||||
public static Sound PlayOneShotScheduledGame(string name, double targetTime, float pitch = 1f, float volume = 1f, bool looping = false, bool forcePlay = false)
|
||||
public static Sound PlayOneShotScheduledGame(string name, double targetTime, float pitch = 1f, float volume = 1f, bool looping = false, bool forcePlay = false, bool ignoreConductorPause = false)
|
||||
{
|
||||
string gameName = name.Split('/')[0];
|
||||
var inf = GameManager.instance.GetGameInfo(gameName);
|
||||
if (GameManager.instance.currentGame == gameName || forcePlay)
|
||||
{
|
||||
return PlayOneShotScheduled($"games/{name}", targetTime, pitch, volume, looping, inf.usesAssetBundle ? gameName : null);
|
||||
return PlayOneShotScheduled($"games/{name}", targetTime, pitch, volume, looping, inf.usesAssetBundle ? gameName : null, ignoreConductorPause);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
Reference in New Issue
Block a user