private IEnumerator DoFreeRecal(int trial_number) { textDisplayer.DisplayText("display day objects recall prompt", LanguageSource.GetLanguageString("day objects recall")); yield return(SkippableWait(RECALL_MESSAGE_DISPLAY_LENGTH)); textDisplayer.ClearText(); highBeep.Play(); scriptedEventReporter.ReportScriptedEvent("Sound played", new Dictionary <string, object>() { { "sound name", "high beep" }, { "sound duration", highBeep.clip.length.ToString() } }); textDisplayer.DisplayText("display recall text", RECALL_TEXT); yield return(SkippableWait(RECALL_TEXT_DISPLAY_LENGTH)); textDisplayer.ClearText(); string output_directory = UnityEPL.GetDataPath(); string wavFilePath = System.IO.Path.Combine(output_directory, trial_number.ToString()) + ".wav"; Dictionary <string, object> recordingData = new Dictionary <string, object>(); recordingData.Add("trial number", trial_number); scriptedEventReporter.ReportScriptedEvent("object recall recording start", recordingData); soundRecorder.StartRecording(wavFilePath); yield return(SkippableWait(FREE_RECALL_LENGTH)); scriptedEventReporter.ReportScriptedEvent("object recall recording stop", recordingData); soundRecorder.StopRecording(); textDisplayer.ClearText(); lowBeep.Play(); scriptedEventReporter.ReportScriptedEvent("Sound played", new Dictionary <string, object>() { { "sound name", "low beep" }, { "sound duration", lowBeep.clip.length.ToString() } }); }
private IEnumerator DoRecall() { VAD.DoVAD(true); highBeep.Play(); scriptedEventReporter.ReportScriptedEvent("Sound played", new Dictionary <string, object>() { { "sound name", "high beep" }, { "sound duration", highBeep.clip.length.ToString() } }); textDisplayer.DisplayText("display recall text", "*******"); yield return(PausableWait(settings.recallTextDisplayLength)); textDisplayer.ClearText(); //path int listno = (wordsSeen / 12) - 1; string output_directory = UnityEPL.GetDataPath(); string wavFilePath = System.IO.Path.Combine(output_directory, listno.ToString() + ".wav"); string lstFilePath = System.IO.Path.Combine(output_directory, listno.ToString() + ".lst"); WriteLstFile(lstFilePath); soundRecorder.StartRecording(wavFilePath); yield return(PausableWait(settings.recallLength)); soundRecorder.StopRecording(); textDisplayer.ClearText(); lowBeep.Play(); scriptedEventReporter.ReportScriptedEvent("Sound played", new Dictionary <string, object>() { { "sound name", "low beep" }, { "sound duration", lowBeep.clip.length.ToString() } }); VAD.DoVAD(false); }
protected IEnumerator DoMicrophoneTest() { microphoneTestMessage.SetActive(true); bool repeat = false; string wavFilePath; do { yield return(PressAnyKey("Press any key to record a sound after the beep.")); lowBeep.Play(); textDisplayer.DisplayText("microphone test recording", "Recording..."); textDisplayer.ChangeColor(Color.red); yield return(new WaitForSeconds(lowBeep.clip.length)); wavFilePath = System.IO.Path.Combine(UnityEPL.GetDataPath(), "microphone_test_" + DataReporter.RealWorldTime().ToString("yyyy-MM-dd_HH_mm_ss") + ".wav"); soundRecorder.StartRecording(wavFilePath); yield return(new WaitForSeconds(MICROPHONE_TEST_LENGTH)); soundRecorder.StopRecording(); textDisplayer.ClearText(); yield return(new WaitForSeconds(MICROPHONE_TEST_GAP)); textDisplayer.DisplayText("microphone test playing", "Playing..."); textDisplayer.ChangeColor(Color.green); audioPlayback.clip = soundRecorder.AudioClipFromDatapath(wavFilePath); audioPlayback.Play(); yield return(new WaitForSeconds(MICROPHONE_TEST_LENGTH)); textDisplayer.ClearText(); textDisplayer.OriginalColor(); SetRamulatorState("WAITING", true, new Dictionary <string, object>()); textDisplayer.DisplayText("microphone test confirmation", "Did you hear the recording? \n(Y=Continue / N=Try Again / C=Cancel)."); while (!Input.GetKeyDown(KeyCode.Y) && !Input.GetKeyDown(KeyCode.N) && !Input.GetKeyDown(KeyCode.C)) { yield return(null); } textDisplayer.ClearText(); SetRamulatorState("WAITING", false, new Dictionary <string, object>()); if (Input.GetKey(KeyCode.C)) { Quit(); } repeat = Input.GetKey(KeyCode.N); }while (repeat); if (!System.IO.File.Exists(wavFilePath)) { yield return(PressAnyKey("WARNING: Wav output file not detected. Sounds may not be successfully recorded to disk.")); } microphoneTestMessage.SetActive(false); }
private void SetSessionNumber() { int nextSessionNumber = 0; UnityEPL.SetSessionNumber(0); while (System.IO.Directory.Exists(UnityEPL.GetDataPath())) { nextSessionNumber++; UnityEPL.SetSessionNumber(nextSessionNumber); } }
private IEnumerator DoCuedRecall(int trial_number) { this_trial_presented_stores.Shuffle(new System.Random()); textDisplayer.DisplayText("display day cued recall prompt", LanguageSource.GetLanguageString("store cue recall")); yield return(SkippableWait(RECALL_MESSAGE_DISPLAY_LENGTH)); textDisplayer.ClearText(); highBeep.Play(); scriptedEventReporter.ReportScriptedEvent("Sound played", new Dictionary <string, object>() { { "sound name", "high beep" }, { "sound duration", highBeep.clip.length.ToString() } }); textDisplayer.DisplayText("display recall text", RECALL_TEXT); yield return(SkippableWait(RECALL_TEXT_DISPLAY_LENGTH)); textDisplayer.ClearText(); foreach (StoreComponent cueStore in this_trial_presented_stores) { cueStore.familiarization_object.SetActive(true); string output_file_name = trial_number.ToString() + "-" + cueStore.GetStoreName(); string output_directory = UnityEPL.GetDataPath(); string wavFilePath = System.IO.Path.Combine(output_directory, output_file_name) + ".wav"; string lstFilepath = System.IO.Path.Combine(output_directory, output_file_name) + ".lst"; AppendWordToLst(lstFilepath, cueStore.GetLastPoppedItemName()); Dictionary <string, object> cuedRecordingData = new Dictionary <string, object>(); cuedRecordingData.Add("trial number", trial_number); cuedRecordingData.Add("store", cueStore.GetStoreName()); cuedRecordingData.Add("item", cueStore.GetLastPoppedItemName()); cuedRecordingData.Add("store position", cueStore.transform.position.ToString()); scriptedEventReporter.ReportScriptedEvent("cued recall recording start", cuedRecordingData); soundRecorder.StartRecording(wavFilePath); yield return(SkippableWait(CUED_RECALL_TIME_PER_STORE)); cueStore.familiarization_object.SetActive(false); scriptedEventReporter.ReportScriptedEvent("cued recall recording stop", cuedRecordingData); soundRecorder.StopRecording(); lowBeep.Play(); scriptedEventReporter.ReportScriptedEvent("Sound played", new Dictionary <string, object>() { { "sound name", "low beep" }, { "sound duration", highBeep.clip.length.ToString() } }); textDisplayer.DisplayText("display recall text", RECALL_TEXT); yield return(SkippableWait(RECALL_TEXT_DISPLAY_LENGTH)); textDisplayer.ClearText(); } }
/// <summary> /// Writes data from the waitingPoints queue to disk. The waitingPoints queue will be automatically updated whenever reporters report data. /// /// DoWrite() will also be automatically be called periodically according to the settings in the component inspector window, but you can invoke this manually if desired. /// </summary> public void DoWrite() { while (waitingPoints.Count > 0) { string directory = UnityEPL.GetDataPath(); System.IO.Directory.CreateDirectory(directory); string filePath = System.IO.Path.Combine(directory, "unnamed_file"); DataPoint dataPoint = waitingPoints.Dequeue(); string writeMe = "unrecognized type"; string extensionlessFileName = "session";//DataReporter.GetStartTime ().ToString("yyyy-MM-dd HH mm ss"); switch (outputFormat) { case FORMAT.JSON_LINES: writeMe = dataPoint.ToJSON(); filePath = System.IO.Path.Combine(directory, extensionlessFileName + ".jsonl"); break; } System.IO.File.AppendAllText(filePath, writeMe + System.Environment.NewLine); } }
private IEnumerator DoDelivery(Environment environment, int trialNumber) { SetRamulatorState("ENCODING", true, new Dictionary <string, object>()); messageImageDisplayer.please_find_the_blah_reminder.SetActive(true); this_trial_presented_stores = new List <StoreComponent>(); List <StoreComponent> unvisitedStores = new List <StoreComponent>(environment.stores); for (int i = 0; i < DELIVERIES_PER_TRIAL; i++) { StoreComponent nextStore = null; int random_store_index = -1; int tries = 0; do { //Debug.Log(tries.ToString()); tries++; random_store_index = Random.Range(0, unvisitedStores.Count); nextStore = unvisitedStores[random_store_index]; }while (nextStore.IsVisible() && tries < 17); unvisitedStores.RemoveAt(random_store_index); playerMovement.Freeze(); messageImageDisplayer.please_find_the_blah_reminder.SetActive(false); messageImageDisplayer.SetReminderText(nextStore.GetStoreName()); yield return(DoPointingTask(nextStore)); messageImageDisplayer.please_find_the_blah_reminder.SetActive(true); playerMovement.Unfreeze(); while (!nextStore.PlayerInDeliveryPosition()) { //Debug.Log(nextStore.IsVisible()); yield return(null); } ///AUDIO PRESENTATION OF OBJECT/// if (i != DELIVERIES_PER_TRIAL - 1) { playerMovement.Freeze(); AudioClip deliveredItem = nextStore.PopItem(); string deliveredItemName = deliveredItem.name; audioPlayback.clip = deliveredItem; audioPlayback.Play(); scriptedEventReporter.ReportScriptedEvent("object presentation begins", new Dictionary <string, object>() { { "trial number", trialNumber }, { "item name", deliveredItemName }, { "store name", nextStore.GetStoreName() }, { "serial position", i + 1 }, { "player position", playerMovement.transform.position.ToString() }, { "store position", nextStore.transform.position.ToString() } }); AppendWordToLst(System.IO.Path.Combine(UnityEPL.GetDataPath(), trialNumber.ToString() + ".lst"), deliveredItemName); this_trial_presented_stores.Add(nextStore); all_presented_objects.Add(deliveredItemName); SetRamulatorState("WORD", true, new Dictionary <string, object>() { { "word", deliveredItemName } }); yield return(SkippableWait(deliveredItem.length)); SetRamulatorState("WORD", false, new Dictionary <string, object>() { { "word", deliveredItemName } }); scriptedEventReporter.ReportScriptedEvent("audio presentation finished", new Dictionary <string, object>()); playerMovement.Unfreeze(); } } messageImageDisplayer.please_find_the_blah_reminder.SetActive(false); SetRamulatorState("ENCODING", false, new Dictionary <string, object>()); }
private IEnumerator DoFinalRecall(Environment environment) { SetRamulatorState("RETRIEVAL", true, new Dictionary <string, object>()); DisplayTitle(LanguageSource.GetLanguageString("all stores recall")); highBeep.Play(); scriptedEventReporter.ReportScriptedEvent("Sound played", new Dictionary <string, object>() { { "sound name", "high beep" }, { "sound duration", highBeep.clip.length.ToString() } }); textDisplayer.DisplayText("display recall text", RECALL_TEXT); yield return(SkippableWait(RECALL_TEXT_DISPLAY_LENGTH)); textDisplayer.ClearText(); string output_directory = UnityEPL.GetDataPath(); string output_file_name = "store recall"; string wavFilePath = System.IO.Path.Combine(output_directory, output_file_name) + ".wav"; string lstFilepath = System.IO.Path.Combine(output_directory, output_file_name) + ".lst"; foreach (StoreComponent store in environment.stores) { AppendWordToLst(lstFilepath, store.GetStoreName()); } scriptedEventReporter.ReportScriptedEvent("final store recall recording start", new Dictionary <string, object>()); soundRecorder.StartRecording(wavFilePath); yield return(SkippableWait(STORE_FINAL_RECALL_LENGTH)); scriptedEventReporter.ReportScriptedEvent("final store recall recording stop", new Dictionary <string, object>()); soundRecorder.StopRecording(); textDisplayer.ClearText(); lowBeep.Play(); scriptedEventReporter.ReportScriptedEvent("Sound played", new Dictionary <string, object>() { { "sound name", "low beep" }, { "sound duration", lowBeep.clip.length.ToString() } }); ClearTitle(); yield return(SkippableWait(TIME_BETWEEN_DIFFERENT_RECALL_PHASES)); DisplayTitle(LanguageSource.GetLanguageString("all objects recall")); highBeep.Play(); scriptedEventReporter.ReportScriptedEvent("Sound played", new Dictionary <string, object>() { { "sound name", "high beep" }, { "sound duration", highBeep.clip.length.ToString() } }); textDisplayer.DisplayText("display recall text", RECALL_TEXT); yield return(SkippableWait(RECALL_TEXT_DISPLAY_LENGTH)); textDisplayer.ClearText(); output_file_name = "final recall"; wavFilePath = System.IO.Path.Combine(output_directory, output_file_name) + ".wav"; lstFilepath = System.IO.Path.Combine(output_directory, output_file_name) + ".lst"; foreach (string deliveredObject in all_presented_objects) { AppendWordToLst(lstFilepath, deliveredObject); } scriptedEventReporter.ReportScriptedEvent("final object recall recording start", new Dictionary <string, object>()); soundRecorder.StartRecording(wavFilePath); yield return(SkippableWait(FINAL_RECALL_LENGTH)); scriptedEventReporter.ReportScriptedEvent("final object recall recording stop", new Dictionary <string, object>()); soundRecorder.StopRecording(); textDisplayer.ClearText(); lowBeep.Play(); scriptedEventReporter.ReportScriptedEvent("Sound played", new Dictionary <string, object>() { { "sound name", "low beep" }, { "sound duration", lowBeep.clip.length.ToString() } }); ClearTitle(); SetRamulatorState("RETRIEVAL", false, new Dictionary <string, object>()); }
private IEnumerator PerformTrial(string[] trial_words, int list_index, bool practice) { float ISI_MIN = 0.8f; float ISI_MAX = 1.2f; float STIMULUS_DISPLAY_LENGTH = 1.6f; float RECALL_LENGTH = 60f; //first isi yield return(new WaitForSeconds(Random.Range(ISI_MIN, ISI_MAX))); //stimulus list for (int sp = 0; sp < lengthOfList; sp++) { string stimulus = trial_words[sp]; Debug.Log(stimulus); scriptedEventReporter.ReportScriptedEvent("stimulus", new Dictionary <string, object> () { { "word", stimulus }, { "index", list_index }, { "ltp word number", GetWordNumber(stimulus) } }); textDisplayer.DisplayText("stimulus display", stimulus); yield return(new WaitForSeconds(STIMULUS_DISPLAY_LENGTH)); scriptedEventReporter.ReportScriptedEvent("stimulus cleared", new Dictionary <string, object>() { { "word", stimulus }, { "index", list_index } }); textDisplayer.ClearText(); //isi yield return(new WaitForSeconds(Random.Range(ISI_MIN, ISI_MAX))); } //recall soundRecorder.StartRecording(); scriptedEventReporter.ReportScriptedEvent("recall start", new Dictionary <string, object>()); textDisplayer.DisplayText("display recall text", "*******"); //begin of recall beep scriptedEventReporter.ReportScriptedEvent("begin beep start", new Dictionary <string, object>()); lowBeep.Play(); yield return(new WaitForSeconds(lowBeep.clip.length)); scriptedEventReporter.ReportScriptedEvent("begin beep stop", new Dictionary <string, object>()); yield return(new WaitForSeconds(RECALL_LENGTH)); textDisplayer.ClearText(); scriptedEventReporter.ReportScriptedEvent("recall stop", new Dictionary <string, object>()); //stop recording and write .wav string wav_path = System.IO.Path.Combine(UnityEPL.GetDataPath(), list_index.ToString() + ".wav"); soundRecorder.StopRecording(wav_path); //write .lst string lst_path = System.IO.Path.Combine(UnityEPL.GetDataPath(), list_index.ToString() + ".lst"); WriteAllLinesNoExtraNewline(lst_path, trial_words); //end of recall beep scriptedEventReporter.ReportScriptedEvent("end beep start", new Dictionary <string, object>()); highBeep.Play(); yield return(new WaitForSeconds(highBeep.clip.length)); scriptedEventReporter.ReportScriptedEvent("end beep stop", new Dictionary <string, object>()); }