Reply To: Saving Recordings with Appropriate Filename

PennController for IBEX Forums Support Saving Recordings with Appropriate Filename Reply To: Saving Recordings with Appropriate Filename

#6605
Jeremy
Keymaster

Hello Danil,

The audio files are named after the MediaRecorder element you created to record them. So if you have newMediaRecorder("recorder","audio") then your files will be named something like recorder.webm. If you have more than one file recorded via a MediaRecorder element called recorder then PennController will automatically append a number to generate unique names, for example recorder-48.webm. Note that the extension in your case is webm and not wav, because no browser natively supports WAV as a format to save audio streams recorded via the MediaRecorder API.

In order to name the files as you describe, you need to do something like

newMediaRecorder([variable.Type,variable.ConditionLabel,variable.BaseFormOfTargetNoun,variable.Numeral,variable.Group].join('_'), "audio")

Of course this is a big long, so I’d suggest you add a column to your table in which you generate the filename you want to use for the recording file for each row. Say you name that column RecordingFile, then you can simply do:

newMediaRecorder(variable.RecordingFile, "audio")

which makes it easier to refer back to your element later, for example:

getMediarecorder(variable.RecordingFile).stop()

Note that I didn’t include a participant ID in those filenames, because the strings you mention are MD5 hashes generated at the end of the experiment. There is no easy way to add a unique participant ID to the filenames, unless if you pass it as part of your experiment’s URL, in which case you can use GetURLParameter to retrieve it, and you can do things like:

newMediaRecorder(variable.RecordingFile+'_'+GetURLParameter("id"), "audio")

and

getMediarecorder(variable.RecordingFile+'_'+GetURLParameter("id")).stop()

Let me know if you have any questions

Jeremy