proper clamping in dialogs
better sync conductor to dsptime (experiment)
This commit is contained in:
parent
b276aad759
commit
4edf062ceb
|
|
@ -12258,7 +12258,7 @@ RectTransform:
|
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 1380.0001, y: -25}
|
||||
m_AnchoredPosition: {x: 1504, y: -25}
|
||||
m_SizeDelta: {x: 360, y: 40}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &456251927
|
||||
|
|
@ -12968,7 +12968,7 @@ MonoBehaviour:
|
|||
m_OnEndEdit:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 0}
|
||||
- m_Target: {fileID: 788904139}
|
||||
m_TargetAssemblyTypeName: TempoDialog, Assembly-CSharp
|
||||
m_MethodName: SetTempo
|
||||
m_Mode: 1
|
||||
|
|
@ -26848,7 +26848,7 @@ MonoBehaviour:
|
|||
m_HandleRect: {fileID: 1589389271}
|
||||
m_Direction: 2
|
||||
m_Value: 1
|
||||
m_Size: 0.99910504
|
||||
m_Size: 0.9999194
|
||||
m_NumberOfSteps: 0
|
||||
m_OnValueChanged:
|
||||
m_PersistentCalls:
|
||||
|
|
@ -27065,7 +27065,7 @@ RectTransform:
|
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 380, y: -20}
|
||||
m_AnchoredPosition: {x: 394, y: -20}
|
||||
m_SizeDelta: {x: 48, y: 30}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &921145189
|
||||
|
|
@ -32704,7 +32704,7 @@ RectTransform:
|
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0.5}
|
||||
m_AnchorMax: {x: 1, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 173.14276}
|
||||
m_AnchoredPosition: {x: 0, y: 173.1428}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 1}
|
||||
--- !u!222 &1154875945
|
||||
|
|
@ -37883,8 +37883,8 @@ RectTransform:
|
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 331, y: -20}
|
||||
m_SizeDelta: {x: 50, y: 50}
|
||||
m_AnchoredPosition: {x: 338, y: -20}
|
||||
m_SizeDelta: {x: 64, y: 50}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1375296290
|
||||
MonoBehaviour:
|
||||
|
|
@ -37906,7 +37906,7 @@ MonoBehaviour:
|
|||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_text: x8
|
||||
m_text: x10
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 4810e200fa0cb24438bac52343d7674b, type: 2}
|
||||
m_sharedMaterial: {fileID: 8580487687356851718, guid: 4810e200fa0cb24438bac52343d7674b, type: 2}
|
||||
|
|
@ -41929,8 +41929,8 @@ RectTransform:
|
|||
m_Father: {fileID: 722008349}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.125, y: 0}
|
||||
m_AnchorMax: {x: 0.125, y: 1}
|
||||
m_AnchorMin: {x: 0.1, y: 0}
|
||||
m_AnchorMax: {x: 0.1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 20, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
|
|
@ -42556,7 +42556,7 @@ RectTransform:
|
|||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0.125, y: 1}
|
||||
m_AnchorMax: {x: 0.1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 10, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
|
|
@ -43175,7 +43175,7 @@ MonoBehaviour:
|
|||
m_HandleRect: {fileID: 1539693732}
|
||||
m_Direction: 0
|
||||
m_MinValue: 0
|
||||
m_MaxValue: 8
|
||||
m_MaxValue: 10
|
||||
m_WholeNumbers: 0
|
||||
m_Value: 1
|
||||
m_OnValueChanged:
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ namespace HeavenStudio
|
|||
double absTime, absTimeAdjust;
|
||||
double dspSizeSeconds;
|
||||
double dspMargin = 128 / 44100.0;
|
||||
bool deferTimeKeeping = false;
|
||||
|
||||
// the dspTime we started at
|
||||
private double dspStart;
|
||||
|
|
@ -186,7 +187,7 @@ namespace HeavenStudio
|
|||
|
||||
startPos = GetSongPosFromBeat(beat);
|
||||
firstBeatOffset = offset;
|
||||
time = startPos;
|
||||
time = startPos - (3 * dspSizeSeconds);
|
||||
|
||||
if (musicSource.clip != null && startPos < musicSource.clip.length - offset)
|
||||
{
|
||||
|
|
@ -199,11 +200,12 @@ namespace HeavenStudio
|
|||
}
|
||||
else
|
||||
{
|
||||
musicScheduledTime = dspTime + (dspMargin * 2);
|
||||
dspStart = dspTime + (dspMargin * 2);
|
||||
musicScheduledTime = dspTime + (3 * dspSizeSeconds);
|
||||
dspStart = dspTime + (3 * dspSizeSeconds);
|
||||
}
|
||||
musicScheduledPitch = SongPitch;
|
||||
musicSource.PlayScheduled(musicScheduledTime);
|
||||
Debug.Log($"playback scheduled for dsptime {dspStart}");
|
||||
}
|
||||
if (musicSource.clip == null)
|
||||
{
|
||||
|
|
@ -215,17 +217,33 @@ namespace HeavenStudio
|
|||
_metronomeTally = 0;
|
||||
|
||||
startTime = DateTime.Now;
|
||||
absTimeAdjust = 0;
|
||||
absTimeAdjust = -(3 * dspSizeSeconds);
|
||||
deferTimeKeeping = (musicSource.clip != null);
|
||||
|
||||
isPlaying = true;
|
||||
isPaused = false;
|
||||
}
|
||||
|
||||
void OnAudioFilterRead(float[] data, int channels)
|
||||
{
|
||||
// don't actually do anything with the data
|
||||
// wait until we get a dsp update before starting to keep time
|
||||
if (deferTimeKeeping && AudioSettings.dspTime >= dspStart)
|
||||
{
|
||||
Debug.Log($"dsptime: {AudioSettings.dspTime}, deferred timekeeping for {DateTime.Now - startTime} seconds");
|
||||
deferTimeKeeping = false;
|
||||
startTime = DateTime.Now;
|
||||
dspStart = AudioSettings.dspTime;
|
||||
absTimeAdjust = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
{
|
||||
if (!isPlaying) return;
|
||||
isPlaying = false;
|
||||
isPaused = true;
|
||||
deferTimeKeeping = false;
|
||||
|
||||
musicSource.Stop();
|
||||
Util.SoundByte.PauseOneShots();
|
||||
|
|
@ -246,6 +264,7 @@ namespace HeavenStudio
|
|||
|
||||
isPlaying = false;
|
||||
isPaused = false;
|
||||
deferTimeKeeping = false;
|
||||
|
||||
musicSource.Stop();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ namespace HeavenStudio.Editor
|
|||
_ => "ok",
|
||||
};
|
||||
|
||||
if (usedCategories.Count == 1)
|
||||
if (usedCategories.Count == 1 || currentEditingRank == Ranks.Ok)
|
||||
{
|
||||
diag.chart["resultcommon_" + propSuffix] = messageInput.text;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ using TMPro;
|
|||
|
||||
public class SectionDialog : Dialog
|
||||
{
|
||||
const float MIN_WEIGHT = 0, MAX_WEIGHT = 10;
|
||||
SectionTimelineObj sectionObj;
|
||||
[SerializeField] TMP_InputField sectionName;
|
||||
[SerializeField] Toggle challengeEnable;
|
||||
|
|
@ -37,8 +38,8 @@ public class SectionDialog : Dialog
|
|||
ResetAllDialogs();
|
||||
dialog.SetActive(true);
|
||||
|
||||
markerWeight.maxValue = 8;
|
||||
markerWeight.minValue = 0;
|
||||
markerWeight.maxValue = MAX_WEIGHT;
|
||||
markerWeight.minValue = MIN_WEIGHT;
|
||||
markerWeight.wholeNumbers = true;
|
||||
|
||||
if (!initHooks)
|
||||
|
|
@ -65,8 +66,8 @@ public class SectionDialog : Dialog
|
|||
challengeEnable.isOn = sectionObj.chartEntity["startPerfect"];
|
||||
markerWeight.value = sectionObj.chartEntity["weight"];
|
||||
|
||||
markerWeight.maxValue = 8;
|
||||
markerWeight.minValue = 0;
|
||||
markerWeight.maxValue = MAX_WEIGHT;
|
||||
markerWeight.minValue = MIN_WEIGHT;
|
||||
markerWeight.wholeNumbers = true;
|
||||
|
||||
UpdateCatButtonState();
|
||||
|
|
@ -109,8 +110,9 @@ public class SectionDialog : Dialog
|
|||
public void SetSectionWeightManual()
|
||||
{
|
||||
if (sectionObj == null) return;
|
||||
sectionObj.chartEntity["weight"] = (float) Math.Round(Convert.ToSingle(markerWeightManual.text), 2);
|
||||
sectionObj.chartEntity["weight"] = Mathf.Round((float)Math.Clamp(Convert.ToSingle(markerWeightManual.text), MIN_WEIGHT, MAX_WEIGHT));
|
||||
markerWeight.value = sectionObj.chartEntity["weight"];
|
||||
markerWeightManual.text = ((float) sectionObj.chartEntity["weight"]).ToString("G");
|
||||
}
|
||||
|
||||
void UpdateCatButtonState()
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public class TempoDialog : Dialog
|
|||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
public void RefreshDialog()
|
||||
{
|
||||
if (tempoObj != null)
|
||||
{
|
||||
|
|
@ -65,6 +65,7 @@ public class TempoDialog : Dialog
|
|||
{
|
||||
float tempo = float.Parse(tempoInput.text);
|
||||
tempoObj.SetTempo(tempo);
|
||||
tempoInput.text = tempoObj.chartEntity["tempo"].ToString("F");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,12 @@ namespace HeavenStudio.Editor.Track
|
|||
if (Input.GetKey(KeyCode.LeftControl))
|
||||
newTempo *= 0.01f;
|
||||
|
||||
SetTempo(chartEntity["tempo"] + newTempo);
|
||||
if (newTempo != 0)
|
||||
{
|
||||
SetTempo(chartEntity["tempo"] + newTempo);
|
||||
tempoDialog.RefreshDialog();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
UpdateTempo();
|
||||
|
|
|
|||
|
|
@ -33,7 +33,11 @@ namespace HeavenStudio.Editor.Track
|
|||
if (Input.GetKey(KeyCode.LeftControl))
|
||||
newVolume *= 0.01f;
|
||||
|
||||
SetVolume(chartEntity["volume"] + newVolume);
|
||||
if (newVolume != 0)
|
||||
{
|
||||
SetVolume(chartEntity["volume"] + newVolume);
|
||||
volumeDialog.RefreshDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
UpdateVolume();
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public class VolumeDialog : Dialog
|
|||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
public void RefreshDialog()
|
||||
{
|
||||
if (volumeObj != null)
|
||||
{
|
||||
|
|
@ -69,8 +69,9 @@ public class VolumeDialog : Dialog
|
|||
{
|
||||
if (volumeObj != null)
|
||||
{
|
||||
volumeObj.SetVolume(volumeSlider.value);
|
||||
volumeInput.text = volumeSlider.value.ToString("F");
|
||||
volumeObj.SetVolume(System.MathF.Round(volumeSlider.value, 2));
|
||||
volumeInput.text = volumeObj.chartEntity["volume"].ToString("F");
|
||||
volumeSlider.value = volumeObj.chartEntity["volume"];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -80,7 +81,8 @@ public class VolumeDialog : Dialog
|
|||
{
|
||||
float volume = float.Parse(volumeInput.text);
|
||||
volumeObj.SetVolume(volume);
|
||||
volumeSlider.value = volume;
|
||||
volumeInput.text = volumeObj.chartEntity["volume"].ToString("F");
|
||||
volumeSlider.value = volumeObj.chartEntity["volume"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue