Error using timeline variables with audio plugins

241 views
Skip to first unread message

ra.ht...@gmail.com

unread,
Aug 11, 2017, 11:23:39 AM8/11/17
to jsPsych
Hi,

I've recently switched from using jsPsych 5.0.3 to the master branch on the github page. I've found some of the new features to be really useful (the vertical alignment was a massive help).

I've been trying to use the new timeline variables feature for an experiment in which the participant is required to listen to an audio clip which plays a different sound to each ear. After listening, the participant is asked to press a button to choose which sound they heard.

However, I've been getting an error which seems to suggest that the audio plugin doesn't work with the timelineVariable method. I've tried wrapping it in a function but that produces the same error.

Here's the code:

var DL_practice = {
timeline: [
{
type: "audio-keyboard-response",
choices: jsPsych.NO_KEYS,
trial_duration: 1000,
prompt: "+",
response_ends_trial: false,
stimulus: jsPsych.timelineVariable('stimulus')
},
{
type: "html-keyboard-response",
choices: ["1", "2", "3", "4", "5", "6"],
timing_post_trial: 500,
stimulus: "<p>Which sound did you hear?</p>" + "<ol><li>ba</li><li>da</li><li>ga</li><li>pa</li><li>ta</li><li>ka</li></ol>",
data: function() {return jsPsych.timelineVariable('data', true)},

}
],
timeline_variables: [
{stimulus: "sounds/ka_ta.wav", data: {LEcresp: 6, REcresp: 5}},
{stimulus: "sounds/ga_pa.wav", data: {LEcresp: 3, REcresp: 4}},
{stimulus: "sounds/da_ba.wav", data: {LEcresp: 2, REcresp: 1}}
]
}

And here's the error I get in the console:

Uncaught TypeError: Failed to set the 'buffer' property on 'AudioBufferSourceNode': The provided value is not of type 'AudioBuffer'.
at Object.jsPsych.plugins.audio-keyboard-response.plugin.trial (jspsych-audio-keyboard-response.js:67)

When I print the timeline variable to the console it returns a string with the correct path to the audio (e.g. "sounds/ka_ta.wav"), and if I specifically type the audio in the stimulus value the experiment works perfectly.

Thanks for your help!

Best wishes,
Jamie Moffatt

ra.ht...@gmail.com

unread,
Aug 23, 2017, 4:26:19 AM8/23/17
to jsPsych, ra.ht...@gmail.com

I figured it out! I had to preload all of the audio files in order to get them to work. I followed the instructions for preloading media (https://github.com/jspsych/jsPsych/blob/master/docs/markdown_docs/features/media-preloading.md) and now the audio works perfectly with timeline variables.

Best,
Jamie

Reply all
Reply to author
Forward
0 new messages