RhythmEngineCore
MonoBehaviour
Last updated
MonoBehaviour
Last updated
Method | Description |
---|---|
AudioSource MusicSource
Audio source that the music is played from.
bool ManualMode
If true, the song won't start playing automatically, you'll have to call SetSong()/SetClip(), InitTime() and Play() manually
bool IsSourcePlaying
True if the music source is playing.
bool HasStarted
True if the current song time is greater than 0
bool IsPaused
True if the song is not playing
float CurrentBpm
Current BPM of the song
double DeltaTime
More accurate version of Time.DeltaTime, it should NOT be used for gameplay purposes, since it's not affected by the audio sync
double AudioDelta
More accurate version of Time.DeltaTime, it can be used for gameplay purposes, since it's affected by the audio sync. However, I would still recommend using stuff like Lerp() with GetCurrentAudioTime() instead of this, since it can skip frames
double SourceStartTime
(Read only) Time in seconds of the moment that the game will unpause on. If you want to set this time, use SetStartTime()
float SongPitch
Music source pitch
Song Song
Currently playing song
Action OnStartPlaying
Called alongside Play(), it's not exactly the same time the audio starts playing, it's just the time that the audio has been scheduled for playback
Action OnStopPlaying
Called on Pause() and Stop()
Action OnBpmChange
Called on bpm change, this is called AFTER the CurrentBpm value has been changed
Action OnLoop
Called when the song loops
InitTime(double time)
Initializes the time of the song, this should be called before playing the song time - Time in seconds
SetSong(Song song, bool setClip)
Set the song that'll be playing, if you'd rather set the clip directly, use SetClip(). song - Song that'll be playing setClip - If true, also set the clip that'll be playing from the song
SetClip(AudioClip clip)
Set the clip of the music source. Can be used instead of SetSong() if you want to create your own gameplay back-end logic for songs. clip - Audio clip of the music that'll be playing
SetOffset(int offsetInMs)
Set the offset of the song, this should be set per user, since it's different for everyone. This also should be preferably set before InitTime() and Play() is called. offsetInMs - Offset in milliseconds
GetCurrentAudioTime()
Return current time of the audio playback, this is the most accurate time you can get from the audio thread, and it should be used for syncing gameplay
Play()
If the time has been initialized, schedules the audio playback. The audio won't start on the same frame as this is called, but the next frame that the audio thread runs.
Unpause()
Unpause the audio playback. Just calls Play()
Pause()
Pause the audio playback
Stop()
Stop the audio playback and reset the time to 0
SetStartTime(double time)
Sets the time that the audio will start playing at. Useful for song editors or gameplay that requires you to start at a specific time in the song