GUIDES
JSON Format:
<br>{</p>
<p>"songURL": "D:\\Laym\\Music\\Dance Wiv Me (feat. Calvin Harris & Chrome).mp3",</p>
<p>"songAlbumCoverURL": "",</p>
<p>"songTitle": "Dance Wiv Me",</p>
<p>"songArtist": "Dizzee Rascal",</p>
<p>"lyrics": [ ... ],</p>
<p>"startTimes": [ ... ],</p>
<p>"durations": [ ... ]</p>
<p>}<br>
How to parse it:
you can use something like this:
public class SongDataParser : MonoBehaviour
{
// SongData class representing the JSON structure
[Serializable]
public class SongData
{
public string songURL;
public string songAlbumCoverURL;
public string songTitle;
public string songArtist;
public List<string> lyrics;
public List<float> startTimes;
public List<float> durations;
}
// Load JSON and parse it
public static SongData LoadSongData(string jsonFilePath)
{
if (!File.Exists(jsonFilePath))
{
Debug.LogError($"File not found at {jsonFilePath}");
return null;
}
try
{
string jsonContent = File.ReadAllText(jsonFilePath);
SongData songData = JsonUtility.FromJson<SongData>(jsonContent);
Debug.Log($"Successfully parsed song data: {songData.songTitle} by {songData.songArtist}");
return songData;
}
catch (Exception e)
{
Debug.LogError($"Failed to parse JSON: {e.Message}");
return null;
}
}
// Example usage
private void Start()
{
string filePath = Path.Combine(Application.dataPath, "songData.json"); // Adjust the path as needed
SongData songData = LoadSongData(filePath);
if (songData != null)
{
Debug.Log($"Song Title: {songData.songTitle}");
Debug.Log($"Lyrics Count: {songData.lyrics.Count}");
// Example: Syncing lyrics with startTimes
for (int i = 0; i < songData.lyrics.Count; i++)
{
Debug.Log($"[{songData.startTimes[i]}s]: {songData.lyrics[i]} (Duration: {songData.durations[i]}s)");
}
}
}
}
Files
Get Karaoke Editor
Karaoke Editor
A simple app that allows anyone to create word-synced lyrics to their favorite songs!
Status | In development |
Category | Tool |
Publisher | |
Author | Laym |
Genre | Rhythm |
Tags | 2D, Graphical User Interface (GUI), lyrics, Music, No AI, Simple, Unity |
Languages | English |
Accessibility | Color-blind friendly, High-contrast |
More posts
- "Patch 1" Update!80 days ago
Leave a comment
Log in with itch.io to leave a comment.