Reading list index in sound component

Hi Jonathan,

Thank you for your response.

One approach that works in PsychoPy is randomizing two lists (say, list A and list B), selecting some stimuli from each list and assigning those stimuli from A and B to a new list called list C. In principle you should be able to assign each list index in list C to a variable which can then be used in a sound component.
Something like the code below does work in PsychoPy but not when uploaded to Pavlovia.

#Make list of major pieces

listA = ("testMusic/A1.wav",
        "testMusic/A2.wav",
        "testMusic/A3.wav",
        "testMusic/A4.wav")

#Make list of minor pieces

listB = ("testMusic/B1.wav",
        "testMusic/B2.wav",
        "testMusic/B3.wav",
        "testMusic/B4.wav")

#Randomly sample two pieces from each list

shufA = np.random.choice(listA, 2, replace = False)
shufB = np.random.choice(listB, 2, replace = False)

#concatenate dataframes 

listC = shufA + shufB

shufC = np.random.shuffle(listC)

#assign pieces to variables

pracPiece1 = shufC[0]
pracPiece2 = shufC[1]
pracPiece3 = shufC[2]
pracPiece4 = shufC[3]

Translating the code to Javascript using something like this code doesn’t seem to work: