Further improvements to AudioSource.time (Conductor.cs)

This commit is contained in:
Starpelly 2021-12-27 21:36:27 -05:00
parent ff6bce2806
commit 75965927d6
17 changed files with 472 additions and 44 deletions

Binary file not shown.

View file

@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: e5cf71158cc9bff4a8fbfbca1e73e500
AudioImporter:
externalObjects: {}
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View file

@ -144,7 +144,64 @@ AnimationClip:
m_RotationOrder: 4
path: Hands/handright
m_ScaleCurves: []
m_FloatCurves: []
m_FloatCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Hands/handstogether
classID: 1
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Hands/handright
classID: 1
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Hands/handleft
classID: 1
script: {fileID: 0}
m_PPtrCurves:
- curve:
- time: 0
@ -181,6 +238,27 @@ AnimationClip:
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- serializedVersion: 2
path: 604036472
attribute: 2086281974
script: {fileID: 0}
typeID: 1
customType: 0
isPPtrCurve: 0
- serializedVersion: 2
path: 73026576
attribute: 2086281974
script: {fileID: 0}
typeID: 1
customType: 0
isPPtrCurve: 0
- serializedVersion: 2
path: 986104082
attribute: 2086281974
script: {fileID: 0}
typeID: 1
customType: 0
isPPtrCurve: 0
- serializedVersion: 2
path: 131153305
attribute: 0
@ -747,6 +825,63 @@ AnimationClip:
path: Hands/handright
classID: 4
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Hands/handstogether
classID: 1
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Hands/handright
classID: 1
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Hands/handleft
classID: 1
script: {fileID: 0}
m_EulerEditorCurves:
- curve:
serializedVersion: 2

View file

@ -7163,7 +7163,7 @@ AudioSource:
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 8300000, guid: c0b3e65059fb3cd49aa056342f2246c8, type: 3}
m_audioClip: {fileID: 8300000, guid: 92cf585c80f8fb843964e525aef1406c, type: 3}
m_PlayOnAwake: 0
m_Volume: 1
m_Pitch: 1
@ -12989,7 +12989,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!114 &1776916805
MonoBehaviour:
m_ObjectHideFlags: 0
@ -14407,12 +14407,13 @@ MonoBehaviour:
playerEntities: []
currentEvent: 0
currentPlayerEvent: 0
txt: {fileID: 4900000, guid: 50b54b23c06076c4598134813da27f18, type: 3}
txt: {fileID: 4900000, guid: 4b7512c586e16a847a5b8490bf35e852, type: 3}
startOffset: 0.5
GameCamera: {fileID: 519420031}
CursorCam: {fileID: 79134728}
CircleCursor: {fileID: 1855769658}
currentGame:
startBeat: 0
--- !u!212 &2072389418
SpriteRenderer:
m_ObjectHideFlags: 0

View file

@ -53,6 +53,10 @@ namespace RhythmHeavenMania
public float beatThreshold;
private float lastTime;
private float lastMst_F;
private int framesSinceLastSame;
void Awake()
{
instance = this;
@ -73,6 +77,12 @@ namespace RhythmHeavenMania
// musicSource.Play();
}
public void Play(float startBeat)
{
musicSource.Play();
}
public void Update()
{
// Conductor.instance.musicSource.pitch = Time.timeScale;
@ -85,11 +95,38 @@ namespace RhythmHeavenMania
else if (pauseTime > 1) { musicSource.UnPause(); pauseTime = 0; }
}*/
float mst = musicSource.timeSamples / (float)musicSource.clip.frequency;
float mst_f = mst + 0;
if (mst == lastTime && musicSource.isPlaying)
{
framesSinceLastSame++;
mst_f = mst_f + (Time.deltaTime * framesSinceLastSame) * musicSource.pitch;
if (mst_f < lastMst_F)
{
mst_f = lastMst_F;
}
print($"{lastMst_F}, {mst_f}");
}
else
{
framesSinceLastSame = 0;
}
lastTime = mst;
lastMst_F = mst_f;
//determine how many seconds since the song started
songPosition = (float)(musicSource.time - dspSongTime - firstBeatOffset);
songPosition = (float)(mst_f - dspSongTime - firstBeatOffset);
//determine how many beats since the song started
songPositionInBeats = songPosition / secPerBeat;
// print($"{musicSource.time}(AudioSource.time), {Time.frameCount}(Time.fasrameCount)");
// print($"{musicSource.time}(0), {mst_f}");
//calculate the loop position
if (songPositionInBeats >= (completedLoops + 1) * beatsPerLoop)

View file

@ -81,7 +81,7 @@ namespace RhythmHeavenMania
// Claps
new GameAction("clap", delegate { ClappyTrio.instance.Clap(currentBeat, currentLength); }, true ),
new GameAction("bop", delegate { ClappyTrio.instance.Bop(); } ),
new GameAction("bop", delegate { ClappyTrio.instance.Bop(currentBeat); } ),
new GameAction("prepare", delegate { ClappyTrio.instance.Prepare(0); } ),
new GameAction("prepare_alt", delegate { ClappyTrio.instance.Prepare(3); } ),

View file

@ -31,6 +31,7 @@ namespace RhythmHeavenMania
Coroutine currentGameSwitchIE;
public string currentGame;
public float startBeat;
private void Awake()
{
@ -55,7 +56,12 @@ namespace RhythmHeavenMania
StartCoroutine(Begin());
SetCurrentGame(eventCaller.GamesHolder.transform.GetComponentsInChildren<Transform>()[1].name);
// SetCurrentGame(eventCaller.GamesHolder.transform.GetComponentsInChildren<Transform>()[1].name);
if (Beatmap.entities.Count >= 1)
{
SetCurrentGame(Beatmap.entities[0].datamodel.Split('/')[0]);
}
}
private IEnumerator Begin()

View file

@ -177,7 +177,7 @@ namespace RhythmHeavenMania.Games.ClappyTrio
Jukebox.PlayOneShotGame("clappyTrio/ready");
}
public void Bop()
public void Bop(float beat)
{
if (playerHitLast)
{
@ -188,15 +188,21 @@ namespace RhythmHeavenMania.Games.ClappyTrio
}
else
{
for (int i = 0; i < Lion.Count; i++)
var a = EventCaller.GetAllInGameManagerList("clappyTrio", new string[] { "clap" });
var b = a.FindAll(c => c.beat < beat);
if (b.Count > 0)
{
if (i == Lion.Count - 1)
for (int i = 0; i < Lion.Count; i++)
{
SetFace(i, 0);
}
else
{
SetFace(i, 2);
if (i == Lion.Count - 1)
{
SetFace(i, 0);
}
else
{
SetFace(i, 2);
}
}
}
}

View file

@ -94,6 +94,9 @@ namespace RhythmHeavenMania.Games.Spaceball
{
allCameraEvents = EventCaller.GetAllInGameManagerList("spaceball", new string[] { "cameraZoom" });
if (allCameraEvents.Count == 0)
currentZoomCamDistance = -10;
if (currentZoomIndex < allCameraEvents.Count && currentZoomIndex >= 0)
{
if (currentZoomIndex - 1 >= 0)

View file

@ -33,7 +33,7 @@ namespace RhythmHeavenMania.Games.Spaceball
if (high) beatLength = 2f;
float normalizedBeatAnim = Conductor.instance.GetLoopPositionFromBeat(startBeat, beatLength + 0.15f);
print(normalizedBeatAnim + " " + Time.frameCount);
// print(normalizedBeatAnim + " " + Time.frameCount);
if (high)
{

View file

@ -37,7 +37,6 @@ namespace RhythmHeavenMania.Games.Spaceball
anim = GetComponent<Animator>();
}
int bruh;
private void Update()
{
if (EligibleHits.Count == 0)
@ -47,12 +46,6 @@ namespace RhythmHeavenMania.Games.Spaceball
{
Swing();
}
if (Conductor.instance.songPositionInBeats >= 5f && bruh == 0)
{
Swing();
bruh++;
}
}
public void SetCostume(int costume)

View file

@ -6,8 +6,10 @@ namespace RhythmHeavenMania.Tests
{
public class WTF : MonoBehaviour
{
private void FixedUpdate()
private void Update()
{
this.gameObject.transform.rotation = Quaternion.Euler(0, 0, Mathf.Lerp(0, 360, Conductor.instance.loopPositionInAnalog));
print(Conductor.instance.loopPositionInAnalog);
}
}
}

38
Assets/cointoss.json Normal file
View file

@ -0,0 +1,38 @@
{
"bpm": 120,
"entities": [
{
"beat": 4,
"datamodel": "spaceball/shootHigh"
},
{
"beat": 8,
"datamodel": "gameManager/switchGame/clappyTrio"
},
{
"beat": 9,
"datamodel": "clappyTrio/bop"
},
{
"beat": 10,
"datamodel": "clappyTrio/bop"
},
{
"beat": 11,
"datamodel": "clappyTrio/prepare_alt"
},
{
"beat": 12,
"length": 1,
"datamodel": "clappyTrio/clap"
},
{
"beat": 16,
"datamodel": "gameManager/switchGame/spaceball"
},
{
"beat": 21,
"datamodel": "spaceball/shoot"
},
]
}

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 244c565c8088cfa4597e0ebda9c7de98
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -2,40 +2,209 @@
"bpm": 135,
"entities": [
{
"beat": 1,
"datamodel": "clappyTrio/prepare_alt"
"beat": 0,
"length": 0,
"valA": 170,
"datamodel": "spaceball/cameraZoom"
},
{
"beat": 0,
"length": 4,
"valA": 10,
"datamodel":"spaceball/cameraZoom"
},
{
"beat": 4,
"type": 1,
"datamodel": "spaceball/shoot"
},
{
"beat": 8,
"length": 42,
"valA": 30,
"datamodel": "spaceball/cameraZoom"
},
{
"beat": 6,
"datamodel": "spaceball/shoot"
},
{
"beat": 8,
"datamodel": "gameManager/switchGame/forkLifter"
},
{
"beat": 8,
"datamodel": "forkLifter/pea"
},
{
"beat": 11,
"datamodel": "gameManager/switchGame/spaceball"
},
{
"beat": 11,
"type": 1,
"datamodel": "spaceball/costume"
},
{
"beat": 14,
"datamodel": "spaceball/shoot"
},
{
"beat": 16,
"datamodel": "gameManager/switchGame/clappyTrio"
},
{
"beat": 17,
"length": 2,
"datamodel": "clappyTrio/clap"
},
{
"beat": 12,
"datamodel": "clappyTrio/prepare_alt"
"beat": 22,
"datamodel": "gameManager/switchGame/spaceball"
},
{
"beat": 13,
"length": 1,
"datamodel": "clappyTrio/clap"
"beat": 22,
"type": 2,
"datamodel": "spaceball/costume"
},
{
"beat": 17,
"beat": 23,
"type": 1,
"datamodel": "spaceball/shootHigh"
},
{
"beat": 26,
"datamodel": "spaceball/shoot"
},
{
"beat": 28,
"datamodel": "spaceball/shootHigh"
},
{
"beat": 28,
"datamodel": "spaceball/shoot"
},
{
"beat": 28,
"datamodel": "forkLifter/pea"
},
{
"beat": 29.5,
"datamodel": "gameManager/switchGame/forkLifter"
},
{
"beat": 17,
"datamodel": "forkLifter/pea"
"beat": 32,
"datamodel": "gameManager/switchGame/spaceball"
},
{
"beat": 20,
"datamodel": "forkLifter/pea"
"beat": 34,
"datamodel": "spaceball/shoot"
},
{
"beat": 20.5,
"datamodel": "forkLifter/pea"
}
"beat": 36,
"datamodel": "spaceball/shoot"
},
{
"beat": 38,
"datamodel": "spaceball/shoot"
},
{
"beat": 40,
"datamodel": "spaceball/shoot"
},
{
"beat": 42,
"datamodel": "spaceball/shoot"
},
{
"beat": 44,
"datamodel": "spaceball/shootHigh"
},
{
"beat": 44,
"length": 2,
"valA": 170,
"datamodel": "spaceball/cameraZoom"
},
{
"beat": 48,
"datamodel":"gameManager/switchGame/forkLifter"
},
{
"beat": 50,
"datamodel":"forkLifter/pea"
},
{
"beat": 53,
"datamodel":"forkLifter/pea"
},
{
"beat": 57,
"datamodel":"gameManager/switchGame/spaceball"
},
{
"beat": 57,
"length": 0,
"valA": 10,
"datamodel":"spaceball/cameraZoom"
},
{
"beat": 57,
"datamodel":"spaceball/shoot"
},
{
"beat": 59,
"datamodel":"spaceball/shoot"
},
{
"beat": 61,
"datamodel":"spaceball/shootHigh"
},
{
"beat": 63,
"datamodel":"spaceball/shoot"
},
{
"beat": 65,
"datamodel":"gameManager/switchGame/clappyTrio"
},
{
"beat": 65,
"length": 1,
"datamodel":"clappyTrio/clap"
},
{
"beat": 68,
"datamodel":"clappyTrio/bop"
},
{
"beat": 69,
"datamodel":"clappyTrio/prepare"
},
{
"beat": 70,
"length": 1,
"datamodel":"clappyTrio/clap"
},
{
"beat": 72.5,
"datamodel":"gameManager/switchGame/forkLifter"
},
{
"beat": 73,
"datamodel":"forkLifter/pea"
},
{
"beat": 75,
"datamodel":"forkLifter/pea"
},
{
"beat": 77,
"datamodel":"forkLifter/pea"
},
{
"beat": 79,
"datamodel":"gameManager/switchGame/spaceball"
},
]
}

View file

@ -1,10 +1,10 @@
{
"bpm": 105,
"bpm": 135,
"entities": [
{
"beat": 0,
"length": 0,
"valA": 20,
"valA": 170,
"datamodel": "spaceball/cameraZoom"
},
{
@ -68,7 +68,7 @@
"datamodel": "spaceball/costume"
},
{
"beat": 22,
"beat": 23,
"type": 1,
"datamodel": "spaceball/shootHigh"
},
@ -125,6 +125,14 @@
"length": 2,
"valA": 170,
"datamodel": "spaceball/cameraZoom"
},
{
"beat": 48,
"datamodel":"gameManager/switchGame/forkLifter"
},
{
"beat": 50,
"datamodel":"forkLifter/pea"
}
]
}

View file

@ -12,6 +12,7 @@ AudioManager:
m_DSPBufferSize: 1024
m_VirtualVoiceCount: 512
m_RealVoiceCount: 32
m_EnableOutputSuspension: 1
m_SpatializerPlugin:
m_AmbisonicDecoderPlugin:
m_DisableAudio: 0