Creative Commons License R.Muralikrishnan, MPI for Empirical Aesthetics. This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Licence.
##############################################################################
##                                                                          ##
##              Read-Aloud Task: Natural Reading of Poems                   ##
##             Experiment Script for use with Presentation                  ##
##             Experimenter:  Maria-Elisabeth Kraxenberger                   ##
##                       Author: R. Muralikrishnan                          ##
##                                                                          ##
##############################################################################

##############################################################################
# Scenario Description Language (SDL) Header Part
##############################################################################

# These button codes have to correspond to those set in 'Settings -> Response'
active_buttons = 9;      # There are 9 active buttons defined in 'Settings -> Response'
button_codes = 1,2,3,4,5,6,7,8,9;    # These are the codes of those buttons

response_matching = simple_matching;  # Enables features not in legacy_matching

# Only those button presses that one expects are logged; not all
response_logging = log_active;

# Needed for EEG Trigger files
#write_codes = true;
#pulse_width = 5;
#default_output_port = 1;  # This is most probably going to be the same for everyone.
# This is the LPT Parallel port that you will define in the Port settings tab of
# Presentation.  This will be used as the output port for sending codes to EEG.
# Defining this here saves getting a port number in the PCL part from the output_manager
# and calling send_code etc.  Stimulus events themselves will send these for us, provided we
# define the correct port_codes in each Stimulus event.

# Default Settings for Font, FG and BG Colours etc.
default_background_color = "232, 240, 247"; # RGB codes in decimal; #000000 => Black
default_font = "Verdana";
default_font_size = 34;
default_text_color = "18, 18, 18"; # "000, 102, 153"; # 006699 A pleasant bluish colour
default_text_align = align_center;

default_deltat = 0;
default_picture_duration = next_picture; #/* This implies that all pictures ...
#/...are shown until the next picture is shown, unless otherwise specified */

#default_all_responses = false;

##############################################################################
# Scenario Description Language (SDL) Part
##############################################################################

begin;

# ============================
# SDL Variable Declarations: -
# ============================

#
# We don't use any variables.  All the timer parameters appear as numbers.

# ==============================
# Picture Stimuli Definitions: - Everything that is shown, including text!
# ==============================

# Screen definition for the trial that starts an Experimental Session.
# Used as the first screen that the participant sees.  Operator Controlled.

# Screen definition for showing a message
picture
{

	box { width = 1920; height = 993; color = 255, 255, 255;};
	x = 0;
	y = 0;

   text { caption = " "; font = "Verdana"; font_size = 18; font_color = "0,0,0";
          background_color = "255,255,255";
          max_text_width = 1200; width = 1240; height = 993; formatted_text = true;}Txt_Message;
   x = 0;
   y = 0;

	box { width = 1920; height = 5; color = 232, 240, 247; }; # Header rule
	x = 0;
	y = 489;

	box { width = 1920; height = 5; color = 232, 240, 247; }; # Footer rule
	x = 0;
	y = -489;

} P_Message;

####  Specific for presenting Visual Stimuli   --------------------------------
# Screen definition for the trial that presents Visual Stimuli (PDF page images).
picture
{

	box { width = 1920; height = 993; color = 255, 255, 255;};
	x = 0;
	y = 0;

	bitmap { filename = "Blank-Page.png"; } Bmp_Visual_Stimulus;
	x = 0;
	y = 0;

	box { width = 1920; height = 5; color = 232, 240, 247; }; # Header rule
	x = 0;
	y = 489;

	box { width = 1920; height = 5; color = 232, 240, 247; }; # Footer rule
	x = 0;
	y = -489;


} P_Visual_Stimulus;

####

#=====================
# Trial Definitions: -
#=====================

/****
/#  Note that the name 'Trial' could be misleading.  Unless otherwise specified,
/#  what we mean by a 'Trial' here is actually a sub-trial or sub-task that is
/#  part - and thereby defines the structure - of an actual experimental trial.
****/

/****
/# Template for defining an SDL Trial.
/# trial
/# {
/#      Trial-related parameters such as trial_duration, trial_type etc.
/#     Trial-related parameters
/#
/#     Stimulus event 1 such as picture, sound, video, nothing or force-FB;
/#     Stimulus event parameters such as time, event code etc.
/#     If the parameters aren't specified, the default values are used!!!
/#
/#     Stimulus event 2;
/#     its parameters...and so on
/# }
****/

# Screen definition of the Trial to show a Blank Screen between Experimental Trials
trial
{
    trial_duration = 300;
    all_responses = false;

    stimulus_event
    {
        #picture {};     # This is the default picture, which is nothing!
        picture P_Message;        # Show P_Message...the text will be filled dynamically in the PCL part below.
        code = "CLS";   # Comment this out to avoid seeing this in the logfile.
    };
} T_Blank_Screen;

# Definition of the Trial to start an Experimental Session.
# Operator Controlled!
trial
{
    trial_duration = forever;       # Keep running the trial...
    trial_type = specific_response; # ...until the following specific response.
    terminator_button = 9;          # Operator PC - ENTER key.

    stimulus_event
    {
        picture P_Message;        # Show P_Message...the text will be filled dynamically in the PCL part below.
        code = "The Experiment starts now!";
    };
} T_Start_Exp;

# Definition of the Trial to continue further.
# Participant Controlled!
trial
{
    trial_duration = forever;        # Keep running the trial...
    trial_type = specific_response;  # ...until the following specific response.
    terminator_button = 8; # Right-Arrow key         # Participant Joystick - L or R button.

    stimulus_event
    {
        picture P_Message;        # Show P_Message...the text will be filled dynamically in the PCL part below.
        code = "CONTINUE";
    };
} T_Continue;

# Definition of the Trial to Launch an Experimental Trial
trial
{
    trial_duration = 400;       # Run the trial for 300 ms...
    all_responses = false;      # ..without recognising any key presses.

    stimulus_event
    {
        picture P_Message;      # Show P_Message...the text will be filled dynamically in the PCL part below.
        code = "";              # Code set below in the PCL program.
        # port_code = ;         # Port code set by the PCL program.
    } E_Launch_New_Trial;
} T_Launch_New_Trial;

####  Specific for presenting Visual Stimuli   --------------------------------
# Definition of the Trial to present Visual Stimuli word-by-word
trial
{
    trial_duration = forever;
    trial_type = specific_response;
    terminator_button = 8;  # Right-Arrow key

    stimulus_event
    {
        picture P_Visual_Stimulus;
        code = "";  # PCL Program fills this!!!
        # port_code = ; # PCL Program fills this!!!
        # target_button = 8; # Right-Arrow key
    } E_Visual_Stimulus;
} T_Visual_Stimulus;

####

####  Specific for presenting Visual Stimuli   --------------------------------
# Definition of the Trial to present a question
trial
{
    trial_duration = forever;
    trial_type = specific_response;
    terminator_button = 1,2,3,4,5,6,7;

    stimulus_event
    {
        picture P_Message;
    } E_Question;

} T_Question;

# Definition of the Trial to show a Pause
# Operator Controlled
trial
{
    trial_duration = forever;
    trial_type = specific_response;
    terminator_button = 8; # Right-Arrow key

    stimulus_event
    {
        picture P_Message;        # Show P_Message...the text will be filled dynamically in the PCL part below.
        code = "PAUSE";
    };
} T_Pause;

# Definition of the Trial to end the session
# Operator Controlled
trial
{
    trial_duration = forever;
    all_responses = false;
    trial_type = first_response;

    stimulus_event
    {
        picture P_Message;        # Show P_Message...the text will be filled dynamically in the PCL part below.
        code = "End of Session!";
    };

} T_End_Thanks;

##############################################################################
# Presentation Control Language (PCL) Program Part
##############################################################################

begin_pcl;

#preset string V_Version; # Prompt the version at the beginning!!!

int N_of_Trials = 8;           # = Number of poems.

# No Sessions Lists for GediVor...there are 8 poems, P-1 to P-8, + P-Practice for practice.
string V_Poems = "P-1.png,P-2.png,P-3.png,P-4.png,P-5.png,P-6.png,P-7.png,P-8.png";
array<string> A_Poems[0];

V_Poems.split(",", A_Poems);
A_Poems.shuffle();

string V_Visual_Stimulus;

####

	     Txt_Message.set_caption("Willkommen!\n\n Wir beginnen jetzt damit, die Gedichte zu präsentieren.\n\nGleich geht es los mit einer kurzen Übung.");
	     Txt_Message.redraw();

        T_Start_Exp.present();


# output_port O_Port_to_EEG = output_port_manager.get_port(1);
stimulus_data D_Stimulus_Data = stimulus_manager.last_stimulus_data();
int D_Last_Response = response_manager.last_response();

#========================
# Main Experiment Loop: -
#========================
loop     /*** Begin Main Loop 1 for Blocks ***/
    int V_Current_Trial = 0  # We start from 0 for GediVor.  The 0th trial is the practice trial!!!

until
    V_Current_Trial > N_of_Trials

begin
	 if V_Current_Trial == 0 then

		  Txt_Message.set_caption("Drücken Sie bitte die rechte Pfeiltaste, um weiterzumachen.");
		  Txt_Message.redraw();

		  T_Continue.present();

	 elseif V_Current_Trial == 1 then

		  Txt_Message.set_caption("Ende der Übung.\n\nBitte sagen Sie der Studienleiterin Bescheid, falls Sie Fragen haben.\n\nWenn Sie keine Fragen haben, drücken Sie bitte die rechte Pfeiltaste, um weiterzumachen.");
		  Txt_Message.redraw();

		  T_Continue.present();

	 else
		  Txt_Message.set_caption("Jetzt kommt eine kurze Pause.\n\nSobald Sie weitermachen möchten,\ndrücken Sie bitte die rechte Pfeiltaste.");
		  Txt_Message.redraw();

		  T_Pause.present();
	 end;


	 if V_Current_Trial == 0 then
			Txt_Message.set_caption("Das Gedicht wird nun zwei Mal präsentiert.\n\nErstes Mal: stilles Lesen\nZweites Mal: lautes Vorlesen\n\nDrücken Sie bitte die Pfeiltaste, um weiterzumachen.");
			Txt_Message.redraw();

		   T_Continue.present();
	 else
		   Txt_Message.set_caption("Gedicht  " + string(V_Current_Trial) + "  von  " +  string(N_of_Trials) + "\n\nDas Gedicht wird nun zwei Mal präsentiert.\n\nErstes Mal: stilles Lesen\nZweites Mal: lautes Vorlesen\n\nDrücken Sie bitte die Pfeiltaste, um weiterzumachen.");
			Txt_Message.redraw();

		   T_Continue.present();
    end;

		   Txt_Message.set_caption("Bitte lesen Sie das Gedicht nun lautlos.\n\nDrücken Sie bitte die Pfeiltaste, um weiterzumachen.");
		   Txt_Message.redraw();

		   T_Continue.present();

		   Txt_Message.set_caption(" ");
		   Txt_Message.redraw();
		   T_Blank_Screen.present();

        # Do filename and event-code assignments valid during this exp-trial;
        # Load wavefile and bitmap stimuli that are needed for this trial;
        /*# We do this before launching the experimental trial so as to keep
          # as minimal intereference as possible in trial timings.  You see,
          # these things consume processor time, however small they are!
        */

         E_Launch_New_Trial.set_event_code("T" + string(V_Current_Trial));

         # Execute the Experimental Trial!!!

         T_Launch_New_Trial.present();                      # Show clear screen for 400 ms

			if V_Current_Trial == 0 then # It is the practice trial!!!
				V_Visual_Stimulus = "P-Practice.png";
			else
				V_Visual_Stimulus =  A_Poems[V_Current_Trial];
			end;

  			# First presentation of the poem
			/*****************  Visual Stimulus Presentation Begins  ***********************/

			# Put the current poem on the picture and redraw the text part in it.
			Bmp_Visual_Stimulus.set_filename(V_Visual_Stimulus);
			Bmp_Visual_Stimulus.load();

			E_Visual_Stimulus.set_event_code(V_Visual_Stimulus + " : Part 1 : read silently");

			# Present the trial that will show the changed text on screen for x ms.
			T_Visual_Stimulus.present();

			E_Visual_Stimulus.set_event_code(V_Visual_Stimulus + " : Part 1 dummy double click");

			# Present the trial that will show the changed text on screen for x ms.
			T_Visual_Stimulus.present();




			/*****************  Visual Stimulus Presentation Ends  *************************/


			T_Blank_Screen.present();


			Txt_Message.set_caption("Wie sehr gefällt Ihnen das Gedicht?\n\ngar nicht                                            sehr gut\n\n1 ___ 2 ___ 3 ___ 4 ___ 5 ___ 6 ___ 7");
			Txt_Message.redraw();

			E_Question.set_event_code("Q1");
			T_Question.present();

			Txt_Message.set_caption("Wie freudig ist das Gedicht?\n\ngar nicht freudig                               sehr freudig\n\n1 ___ 2 ___ 3 ___ 4 ___ 5 ___ 6 ___ 7");
			Txt_Message.redraw();

			E_Question.set_event_code("Q2");
			T_Question.present();

			Txt_Message.set_caption("Wie traurig ist das Gedicht?\n\ngar nicht traurig                               sehr traurig\n\n1 ___ 2 ___ 3 ___ 4 ___ 5 ___ 6 ___ 7");
			Txt_Message.redraw();

			E_Question.set_event_code("Q3");
			T_Question.present();

			Txt_Message.set_caption("Bitte lesen Sie das Gedicht nun laut vor.\n\nDrücken Sie bitte die Pfeiltaste, um weiterzumachen.");	     Txt_Message.redraw();
			Txt_Message.redraw();
			T_Continue.present();


  			# Second presentation of the identical poem
			/*****************  Visual Stimulus Presentation Begins  ***********************/

			E_Visual_Stimulus.set_event_code(V_Visual_Stimulus + " : Part 2 : read aloud");
			T_Visual_Stimulus.present();

			E_Visual_Stimulus.set_event_code(V_Visual_Stimulus + " : Part 2 dummy double click");
			T_Visual_Stimulus.present();

			/*****************  Visual Stimulus Presentation Ends  *************************/

      # Go to the Next Trial
      V_Current_Trial = V_Current_Trial + 1;

#================
# End Main Loop 1
#================
end;    /*** End Main Loop 1 for Blocks ***/


Txt_Message.set_caption("Sie haben es geschafft.\nVielen Dank!");
Txt_Message.redraw();

# Finish off the session!!!
T_End_Thanks.present();