146 lines
4.5 KiB
GDScript3
146 lines
4.5 KiB
GDScript3
extends Node
|
|
|
|
# Declare member variables here. Examples:
|
|
# var a = 2
|
|
# var b = "text"
|
|
var SongTitle = ""
|
|
var SongArtist = ""
|
|
var CompletionType
|
|
var Tags = ""
|
|
var OriginalURL = ""
|
|
var PartsURLs = []
|
|
var PartsVolumes = []
|
|
var PartsDelays = []
|
|
var PartsOthers = []
|
|
var BackVolume = 0
|
|
|
|
enum CompletionTypeOptions {
|
|
OpenSeed,
|
|
SoloCompletion,
|
|
DuetCompletion,
|
|
AllHarmony,
|
|
AllMelody
|
|
}
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready():
|
|
print(unBundle("""Hey, I sang part of Don't Give Up by Peter Gabriel at https://no.where and it's not complete until you sing the rest of it with me!
|
|
With #ASingCrow, you can join it and other songs.
|
|
The audio track(s) are attached.
|
|
Backing volume recommendation: 1db.
|
|
Parts volume recommendations: 40db, 40db.
|
|
Audio delay recommendations: 0.166s
|
|
#test #ignore
|
|
"""))
|
|
pass # Replace with function body.
|
|
|
|
func setSongTitle(value):
|
|
SongTitle = value
|
|
|
|
func setSongArtist(value):
|
|
SongArtist = value
|
|
|
|
func setCompletionType(value):
|
|
CompletionType = value
|
|
|
|
func setTags(value):
|
|
Tags = value
|
|
|
|
func setOriginalURL(value):
|
|
OriginalURL = value
|
|
|
|
func setPartsURLs(value):
|
|
PartsURLs = value
|
|
|
|
func setPartsVolumes(value):
|
|
PartsVolumes = value
|
|
|
|
func setPartsDelays(value):
|
|
PartsDelays = value
|
|
|
|
func setBackVolume(value):
|
|
BackVolume = value
|
|
|
|
func getFinalText():
|
|
var completiontext = ""
|
|
var partof = ""
|
|
var i = 0
|
|
match CompletionType :
|
|
CompletionTypeOptions.OpenSeed:
|
|
completiontext = " and it's not complete until you sing the rest of it with me!"
|
|
partof = "part of "
|
|
CompletionTypeOptions.SoloCompletion:
|
|
completiontext = " let me know what you think!"
|
|
CompletionTypeOptions.DuetCompletion:
|
|
completiontext = " with "+PartsOthers+" and it sounds great, don't you think!?"
|
|
CompletionTypeOptions.AllHarmony:
|
|
partof = "only the harmonies of "
|
|
completiontext = " and would love someone to put the melody on top!"
|
|
CompletionTypeOptions.AllMelody:
|
|
partof = "only the melody of "
|
|
completiontext = " and would love someone to put some harmonies underneath!"
|
|
var partstext = "The audio track(s) are attached"
|
|
if len(PartsURLs) > 0:
|
|
partstext = "The audio track urls are :"
|
|
for parturl in PartsURLs:
|
|
partstext += " "+parturl
|
|
partstext += ".\n"
|
|
var volumetext = "Backing volume recommendation: "+String(BackVolume)+"db.\nParts volume recommendations: "
|
|
i = 0
|
|
for partvolume in PartsVolumes:
|
|
volumetext += String(partvolume)+"db"
|
|
if len(PartsVolumes) > i+1:
|
|
volumetext += ", "
|
|
i += 1
|
|
volumetext += ".\n"
|
|
var partdelaytext = "Audio delay recommendations: "
|
|
i = 0
|
|
for partDelay in PartsDelays:
|
|
partdelaytext += String(partDelay)+"s"
|
|
if len(PartsDelays) > i+1:
|
|
partdelaytext += ", "
|
|
return "Hey, I sang "+partof+SongTitle+" by "+SongArtist+" at "+OriginalURL+completiontext+" "+\
|
|
"\nWith #ASingCrow, you can join it and other songs.\n"+partstext+volumetext+partdelaytext+"\n"+Tags
|
|
|
|
func unBundle(text):
|
|
var result = {}
|
|
var regex = RegEx.new()
|
|
regex.compile("(part of|only the (?<parttype>\\w) of) (?<trackname>.+) by (?<originalartist>.+) at (?<trackurl>[^ ]*) (and[^!]*!|let[^!]*!|with[^!]*!)")
|
|
var search = regex.search(text)
|
|
result.parttype = search.get_string("parttype")
|
|
result.trackname = search.get_string("trackname")
|
|
result.originalartist = search.get_string("originalartist")
|
|
result.trackurl = search.get_string("trackurl")
|
|
regex.compile("(?<embeddedaudio>audio track(s|\\(s\\))? are attached)|audio track urls are : (?<trackurls>.*)")
|
|
search = regex.search(text)
|
|
if search.get_string("embeddedaudio"):
|
|
result.embeddedaudio = true
|
|
else:
|
|
result.embeddedaudio = false
|
|
regex.compile("Backing volume recommendation: (?<mainvol>[^d]+)db")
|
|
search = regex.search(text)
|
|
result.mainvol = search.get_string("mainvol")
|
|
regex.compile("Parts volume recommendations: (?<partvol>([^d]+db(, )?)+)")
|
|
search = regex.search(text)
|
|
var partsstr = search.get_string("partvol")
|
|
regex.compile("(?<db>[\\d\\.]+)db")
|
|
search = regex.search_all(partsstr)
|
|
var partvols = []
|
|
for each in search:
|
|
partvols.append(each.get_string("db"))
|
|
result.partvols = partvols
|
|
regex.compile("Audio delay recommendations: (?<partsdelays>([\\d\\.]+s(, )?)+)")
|
|
search = regex.search(text)
|
|
partsstr = search.get_string("partsdelays")
|
|
regex.compile("(?<seconds>[\\d\\.]+)s")
|
|
search = regex.search_all(partsstr)
|
|
var partsdelays = []
|
|
for each in search:
|
|
partsdelays.append(each.get_string("seconds"))
|
|
result.partsdelays = partsdelays
|
|
return result
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
#func _process(delta):
|
|
# pass
|