Skip to content

Commit b463631

Browse files
fix: fixed the audio delay introduced by vrchat
Co-authored-by: DeltaNeverUsed <[email protected]>
1 parent f333f11 commit b463631

File tree

10 files changed

+26
-13
lines changed

10 files changed

+26
-13
lines changed

Docs/osd_ui_preview.png

-122 KB
Loading

Packages/befuddledlabs.opensyncdance/Runtime/OpenSyncDance.cs

+11-2
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,6 @@ private void GenerateReceiveLayer()
663663
readyState.TrackingTracks(AacAv3.Av3TrackingElement.LeftFingers);
664664
readyState.TrackingTracks(AacAv3.Av3TrackingElement.RightFingers);
665665

666-
danceState.PlayableEnables(VRC_PlayableLayerControl.BlendableLayer.Action);
667666
readyState.PlayableDisables(VRC_PlayableLayerControl.BlendableLayer.Action);
668667

669668
// Transition to dance blend tree whenever an animation is triggered
@@ -672,10 +671,13 @@ private void GenerateReceiveLayer()
672671
danceState.TransitionsTo(readyState);
673672

674673
var paramRecvBitsWrapped = new AacFlBoolGroupDecisionParameter(_paramRecvBits, _numberOfBits);
675-
foreach (var (entryState, parent, param) in Utils.CreateBinarySearchTree(new AacFlStateMachineWrapped(danceState), paramRecvBitsWrapped))
674+
foreach (var (waitState, parent, param) in Utils.CreateBinarySearchTree(new AacFlStateMachineWrapped(danceState), paramRecvBitsWrapped))
676675
{
676+
var waitDoneState = parent.NewState("waitState");
677+
var entryState = parent.NewState("entryState");
677678
var loopState = parent.NewState("loopState");
678679
var exitState = parent.NewState("exitState");
680+
679681
entryState.TransitionsTo(exitState).When(param.ExitCondition);
680682
entryState.TransitionsTo(loopState).Automatically();
681683
loopState.TransitionsTo(exitState).When(param.ExitCondition);
@@ -688,6 +690,13 @@ private void GenerateReceiveLayer()
688690

689691
var item = _animations[param.id - 1];
690692

693+
// HACK: For some reason VRChat's play audio state behaviour has a delay.
694+
// We delay the action animation to match with the delayed audio.
695+
waitState.TransitionsTo(waitDoneState).WithTransitionDurationSeconds(0.25f).When(_recvLayer.BoolParameter("false").IsFalse());
696+
waitDoneState.TransitionsTo(entryState).Automatically();
697+
698+
entryState.PlayableEnables(VRC_PlayableLayerControl.BlendableLayer.Action);
699+
691700
entryState.TrackingAnimates(AacAv3.Av3TrackingElement.Head);
692701
entryState.TrackingAnimates(AacAv3.Av3TrackingElement.LeftHand);
693702
entryState.TrackingAnimates(AacAv3.Av3TrackingElement.RightHand);
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:a599b965f37af693aae15364294b219aac2ecce46dc8d23f7d29f490ea645e9d
3-
size 17802827
2+
oid sha256:b54dd7c376efb19c1e4d285f82fe7786490e377711ad818a0bc9ebb2341629a3
3+
size 17803101
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:af5ac192539b7efbb5879a51809cdd03a7a4dea6a40e790ab70b0085a510acdb
3-
size 1320311
2+
oid sha256:65949f925343ef873d2ea0a286d835a6a38608d3fc30587997b291cff856caf3
3+
size 1460138
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:b50b54a4d5733242ffcc6f6c89fddc8f156f0abca42cfebae9a746d2b4fcee0d
3-
size 9367407
2+
oid sha256:dabb9ca090560b983408961c77361768637947f31ea924f6119ab2bf98f5d8b5
3+
size 12269576

Packages/befuddledlabs.opensyncdance/Samples/VRChat/OSD_Menu_0.asset

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ MonoBehaviour:
1212
m_Script: {fileID: -340790334, guid: 67cc4cb7839cd3741b63733d5adf0442, type: 3}
1313
m_Name: OSD_Menu_0
1414
m_EditorClassIdentifier:
15+
Parameters: {fileID: 0}
1516
controls:
1617
- name: Page 1
1718
icon: {fileID: 0}

Packages/befuddledlabs.opensyncdance/Samples/VRChat/OSD_Menu_1.asset

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ MonoBehaviour:
1212
m_Script: {fileID: -340790334, guid: 67cc4cb7839cd3741b63733d5adf0442, type: 3}
1313
m_Name: OSD_Menu_1
1414
m_EditorClassIdentifier:
15+
Parameters: {fileID: 0}
1516
controls:
1617
- name: Page 2
1718
icon: {fileID: 0}

Packages/befuddledlabs.opensyncdance/Samples/VRChat/OSD_Menu_2.asset

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ MonoBehaviour:
1212
m_Script: {fileID: -340790334, guid: 67cc4cb7839cd3741b63733d5adf0442, type: 3}
1313
m_Name: OSD_Menu_2
1414
m_EditorClassIdentifier:
15+
Parameters: {fileID: 0}
1516
controls:
1617
- name: Geddan
1718
icon: {fileID: 0}

Packages/befuddledlabs.opensyncdance/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "befuddledlabs.opensyncdance",
33
"displayName": "Open Sync Dance",
4-
"version": "0.1.1",
4+
"version": "0.1.2",
55
"url": "https://github.com/BefuddledLabs/OpenSyncDance",
66
"author": {
77
"name": "BefuddledLabs"

README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Open Sync Dance is a utility and Unity prefab to have player-synchronized dances
88
## Dependencies
99

1010
- [Haï's Animator As Code](https://github.com/hai-vr/av3-animator-as-code)
11-
- [Haï's Animator As Code - VRChat](https://github.com/hai-vr/animator-as-code-vrchat), version `1.1.0-beta` or higher
11+
- [Haï's Animator As Code - VRChat](https://github.com/hai-vr/animator-as-code-vrchat), version `1.1.0` or higher
1212
- [VRCFury (optional)](https://vrcfury.com/)
1313

1414
## How to use
@@ -17,8 +17,9 @@ Open Sync Dance is a utility and Unity prefab to have player-synchronized dances
1717
2. Add the Open Sync Dance package to VCC via the listing at [`befuddledlabs.github.io/OpenSyncDance`](https://befuddledlabs.github.io/OpenSyncDance/).
1818
3. Drag and drop the `OpenSyncDance` prefab from `Packages/Open Sync Dance/Samples` onto a VRChat avatar.
1919
4. On the prefab, download the missing audio clips. This will download from the supplied URLs and cut them to length. You can configure other things here too, like selecting animations and swapping songs.
20-
5. If you have VRCFury, the avatar will be ready to upload. If not, please merge the animators, parameters and menu 0 with your current avatar.
21-
6. Upload & dance! 💃💃
20+
5. **Click the Generate button!**
21+
6. If you have VRCFury, the avatar will be ready to upload. If not, please merge the animators, parameters and menu 0 with your current avatar.
22+
7. Upload & dance! 💃💃
2223

2324
## Included Dances
2425

@@ -51,7 +52,7 @@ To make modifications to this package:
5152
- [*DeltaNeverUsed*](https://github.com/DeltaNeverUsed) 💻
5253
- [*Nara*](https://github.com/Naraenda) 💻
5354
- [*Airishayn*](https://x.com/Airishayn1/) 🎨
54-
- For making the banner for the package listing
55+
- For making the banner for the package listing.
5556
- [*THEDAO77*](https://thedao77.booth.pm/) 💃
5657
- For allowing us to redistribute animation files.
5758
- [*Krysiek*](https://github.com/Krysiek) 💃

0 commit comments

Comments
 (0)