mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-13 08:47:39 +02:00
Note param stuff + some other fixes
This commit is contained in:
@ -33,8 +33,21 @@ namespace HeavenStudio
|
||||
public int sampleNote;
|
||||
public int sampleOctave;
|
||||
public string sampleName;
|
||||
public bool offsetToC;
|
||||
|
||||
public Note(int val = 0, int sampleNote = 0, int sampleOctave = 4, string sampleName = null, bool offsetToC = true)
|
||||
{
|
||||
min = -maxSemitones;
|
||||
max = maxSemitones;
|
||||
|
||||
this.val = val;
|
||||
this.sampleNote = sampleNote;
|
||||
this.sampleOctave = sampleOctave;
|
||||
this.sampleName = sampleName;
|
||||
this.offsetToC = offsetToC;
|
||||
}
|
||||
|
||||
public Note(int min, int max, int val = 0, int sampleNote = 0, int sampleOctave = 0, string sampleName = "")
|
||||
public Note(int min, int max, int val = 0, int sampleNote = 0, int sampleOctave = 4, string sampleName = null, bool offsetToC = true)
|
||||
{
|
||||
this.min = min;
|
||||
this.val = val;
|
||||
@ -42,6 +55,7 @@ namespace HeavenStudio
|
||||
this.sampleNote = sampleNote;
|
||||
this.sampleOctave = sampleOctave;
|
||||
this.sampleName = sampleName;
|
||||
this.offsetToC = offsetToC;
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,7 +121,21 @@ namespace HeavenStudio
|
||||
this.values = values.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public struct NoteSampleDropdown
|
||||
{
|
||||
public object defaultValue;
|
||||
public Func<object, NoteSample> getNoteSample;
|
||||
public string semisProp;
|
||||
|
||||
public NoteSampleDropdown(object defaultValue, Func<object, NoteSample> getNoteSample, string semisProp)
|
||||
{
|
||||
this.defaultValue = defaultValue;
|
||||
this.getNoteSample = getNoteSample;
|
||||
this.semisProp = semisProp;
|
||||
}
|
||||
}
|
||||
|
||||
public class DropdownObj
|
||||
{
|
||||
public void SetValues(List<string> values)
|
||||
|
@ -40,6 +40,8 @@ namespace HeavenStudio.Util
|
||||
|
||||
const double PREBAKE_TIME = 0.25;
|
||||
|
||||
private Coroutine fadeRoutine;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
}
|
||||
@ -68,6 +70,8 @@ namespace HeavenStudio.Util
|
||||
GameManager.instance.SoundObjects.Release(this);
|
||||
return;
|
||||
}
|
||||
|
||||
CancelFadeRoutine();
|
||||
|
||||
audioSource = GetComponent<AudioSource>();
|
||||
cond = Conductor.instance;
|
||||
@ -234,12 +238,15 @@ namespace HeavenStudio.Util
|
||||
audioSource.UnPause();
|
||||
}
|
||||
|
||||
public void Stop(bool releaseToPool = false)
|
||||
/// <summary>
|
||||
/// Used internally to stop and reset the sound once it has been released back into the pool.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// WARNING! You should use <see cref="KillLoop">KillLoop()</see> to stop sounds early, not this!
|
||||
/// </remarks>
|
||||
public void Stop()
|
||||
{
|
||||
if(releaseToPool && audioSource.isPlaying)
|
||||
{
|
||||
GameManager.instance.SoundObjects.Release(this);
|
||||
}
|
||||
CancelFadeRoutine();
|
||||
|
||||
available = true;
|
||||
played = false;
|
||||
@ -318,21 +325,30 @@ namespace HeavenStudio.Util
|
||||
|
||||
#endregion
|
||||
|
||||
public void KillLoop(double fadeTime)
|
||||
/// <summary>
|
||||
/// Fades the sound out over fadeTime, then releases it back into the pool which stops it.
|
||||
/// Leave fadeTime at 0 to stop the sound instantly.
|
||||
/// You should use this for stopping sounds early, not <see cref="Stop"/>.
|
||||
/// </summary>
|
||||
public void KillLoop(double fadeTime = 0)
|
||||
{
|
||||
if (!gameObject.activeSelf) return;
|
||||
|
||||
CancelFadeRoutine();
|
||||
|
||||
if (fadeTime == 0)
|
||||
{
|
||||
GameManager.instance.SoundObjects.Release(this);
|
||||
return;
|
||||
}
|
||||
StartCoroutine(FadeLoop(fadeTime));
|
||||
|
||||
fadeRoutine = StartCoroutine(FadeLoop(fadeTime));
|
||||
}
|
||||
|
||||
double loopFadeTimer = 0f;
|
||||
IEnumerator FadeLoop(double fadeTime)
|
||||
{
|
||||
float startingVol = audioSource.volume;
|
||||
float loopFadeTimer = 0f;
|
||||
|
||||
while (loopFadeTimer < fadeTime)
|
||||
{
|
||||
@ -341,7 +357,13 @@ namespace HeavenStudio.Util
|
||||
yield return null;
|
||||
}
|
||||
yield return null;
|
||||
|
||||
GameManager.instance.SoundObjects.Release(this);
|
||||
}
|
||||
|
||||
private void CancelFadeRoutine()
|
||||
{
|
||||
if(fadeRoutine != null) StopCoroutine(fadeRoutine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user