well one of the benefits of me being spite-motivated and easily pissed off is im still so mad about getting that shitty feedback yesterday that today i sat down and decided to see if i could code a seamless-audio-looping-with-reverb-tail mechanic direct in Unity instead of having to use middleware like Wwise, and i am happy to report that it actually was super easy and i did it in like an hour.
i really, REALLY don't think anyone who follows me is in need of coding seamless audio looping with reverb tail direct in Unity, but uh, if you happen to be, here you go under the cut. all u have to do is drag in 2 audio sources with the same audio file that has reverb tail baked in, then enter the # of bars, bpm, and beats per measure and it'll handle the rest
big thanks to this tutorial for going over the basics of AudioSource.PlayScheduled - https://johnleonardfrench.com/ultimate-guide-to-playscheduled-in-unity/#play_scheduled_intro
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ReverbLoop : MonoBehaviour
{
public int bars;
public int bpm;
public int beatsInMeasure;
private double barlength;
private double repeatlength;
private double goTime;
private bool zero;[Tooltip("Drag in 2 audio sources that are the same track each with reverb tail baked in. They will alternate to create a seamless loop.")] public List<AudioSource> trackDupes; private void Start() { goTime = AudioSettings.dspTime + 0.5; Calculate(); } private void Calculate() { barlength = 60d / bpm * beatsInMeasure; repeatlength = barlength * bars; } private void Prepare() { if (zero) { //the last playscheduled we did was for the zeroeth one trackDupes[1].PlayScheduled(goTime); } else { trackDupes[0].PlayScheduled(goTime); } goTime = goTime + repeatlength; zero = !zero; } private void Update() { if (AudioSettings.dspTime > goTime - 1) { Prepare(); } }
Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
✓ Live Streaming✓ Interactive Chat✓ Private Shows✓ HD Quality
Anya is LIVE right now
FREE
Free to watch • No registration required • HD streaming
Top Posts Tagged with #unity audio implementation | Tumlook