I have been playing around with the sound generator looking for cool sounds. How would you save something like this into a variable? I want to make a table of such variables that I find enjoyable and give them descriptive Keys, and then just call sound(key).
However, I do not know out how to do this.
mySounds = {}
--rocket
sound(DATA, "ZgNAfwA/Qx0CPSxrP0FVv3etHDxOeCY/VwAzekRAKVJFJAcZ")
Couldn’t you just say mySounds.rocket=sound()
, and if that didn’t work you could just save the string.
@xThomas Put your sounds in a table. Here’s an example.
function setup()
tab={"ZgNAfwA/Qx0CPSxrP0FVv3etHDxOeCY/VwAzekRAKVJFJAcZ"}
sound(DATA,tab[1])
end
or like this. Change the data in tab for different rocket sounds.
function setup()
parameter.integer("select",1,3,1)
name={"rocket1","rocket2","rocket3"}
tab={rocket1="ZgNAfwA/Qx0CPSxrP0FVv3etHDxOeCY/VwAzekRAKVJFJAcZ",
rocket2="ZgNAfwA/Qx0CPSxrP0FVv3etHDxOeCY/VwAzekRAKVJFJAcZ",
rocket3="ZgNAfwA/Qx0CPSxrP0FVv3etHDxOeCY/VwAzekRAKVJFJAcZ"}
end
function draw()
background(0)
fill(255)
text("Use parameter to select sound",WIDTH/2,HEIGHT/2+100)
text("tap screen for..."..name[select],WIDTH/2,HEIGHT/2)
end
function touched(t)
if t.state==BEGAN then
sound(DATA,tab[name[select]])
end
end