2020-09-27 20:58:03 +00:00
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 ( ) :
2020-10-09 10:19:56 +00:00
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 : 1 db .
Parts volume recommendations : 40 db , 40 db .
Audio delay recommendations : 0.166 s
#test #ignore
""" ))
2020-09-27 20:58:03 +00:00
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 = " "
2020-10-09 10:19:56 +00:00
var i = 0
2020-09-27 20:58:03 +00:00
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! "
2020-10-09 10:19:56 +00:00
var partstext = " The audio track(s) are attached "
2020-09-27 20:58:03 +00:00
if len ( PartsURLs ) > 0 :
partstext = " The audio track urls are : "
for parturl in PartsURLs :
partstext += " " + parturl
partstext += " . \n "
2020-10-09 10:19:56 +00:00
var volumetext = " Backing volume recommendation: " + String ( BackVolume ) + " db. \n Parts volume recommendations: "
i = 0
2020-09-27 20:58:03 +00:00
for partvolume in PartsVolumes :
2020-10-09 10:19:56 +00:00
volumetext += String ( partvolume ) + " db "
if len ( PartsVolumes ) > i + 1 :
volumetext += " , "
i += 1
2020-09-27 20:58:03 +00:00
volumetext += " . \n "
var partdelaytext = " Audio delay recommendations: "
2020-10-09 10:19:56 +00:00
i = 0
2020-09-27 20:58:03 +00:00
for partDelay in PartsDelays :
2020-10-09 10:19:56 +00:00
partdelaytext += String ( partDelay ) + " s "
if len ( PartsDelays ) > i + 1 :
partdelaytext += " , "
2020-09-27 20:58:03 +00:00
return " Hey, I sang " + partof + SongTitle + " by " + SongArtist + " at " + OriginalURL + completiontext + " " + \
2020-10-09 10:19:56 +00:00
" \n With #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
2020-09-27 20:58:03 +00:00
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass