<?php

	ini_set('display_errors',1);
	ini_set('display_startup_errors',1);
	error_reporting(-1);

	include("status.php");
	$_SESSION["survey"] = 1;

$url = 'https://serv.cusp.nyu.edu/files/sonyc/test_sequences/json/sequence_data.json';
$soundinfo = json_decode(file_get_contents($url),true);

if (isset($_SESSION["randNum1"])) {
	$randNum1 = $_SESSION["randNum1"];
}
else {
	$randNum1 = rand(0, 99);
	$_SESSION["randNum1"] = $randNum1;
}

if (isset($_SESSION["randNum2"])) {
	$randNum2 = $_SESSION["randNum2"];
}
else {
	$randNum2 = rand(0, 99);
	$_SESSION["randNum2"] = $randNum2;
}

//echo $soundinfo[$filename]['ntones'];

$link1 = "https://serv.cusp.nyu.edu/files/sonyc/test_sequences/mp3/tone_sequence_".strval($randNum1);
$link2 = "https://serv.cusp.nyu.edu/files/sonyc/test_sequences/mp3/tone_sequence_".strval($randNum2);

?>

<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Urban Soundtagging</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/bootstrap-theme.min.css" rel="stylesheet">
    <link href="style.css" rel="stylesheet">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js does not work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
    <div class="container">
      <div>
		<form action = "check.php" method = "POST">
        <h1>Sound Test</h1>
		<p>Participation in this project requires headphones. Please connect your headphones now and follow the steps below. After you complete the instructions on this page, please be sure to keep your headphones on for the remainder of your participation.<p>
        <h2>Step 1</h2>
		<p>Find a quiet place with no background noise</p>
		<h2>Step 2</h2>
		<p>Put on good quality headphones (<strong>Note:</strong> Do not listen over speakers)</p>
		<h2>Step 3</h2>
		<p>Listen to the <strong>entire</strong> audio file below using headphones and count how many tones you hear</p>
		<audio controls>
		  <source src="<?php echo $link1.'.mp3'; ?>" type="audio/mpeg">
		  <source src="<?php echo $link1.'.wav'; ?>" type="audio/wav">
		Your browser does not support mp3 or wav playback.
		</audio>
		<br><br>
		<p>How many tones did you hear?</p>
		<input type="radio" name="first" value="1">1
		<input type="radio" name="first" value="2">2
		<input type="radio" name="first" value="3">3
		<input type="radio" name="first" value="4">4
		<input type="radio" name="first" value="5">5
		<input type="radio" name="first" value="6">6
		<input type="radio" name="first" value="7">7
		<input type="radio" name="first" value="8">8
		<br>
		<h2>Step 4</h2>
		<p>Listen to the <strong>entire</strong> audio file below using headphones and count how many tones you hear</p>
		<audio controls>
		  <source src="<?php echo $link2.'.mp3'; ?>" type="audio/mpeg">
		  <source src="<?php echo $link2.'.wav'; ?>" type="audio/wav">
		Your browser does not support mp3 or wav playback.
		</audio>
		<br><br>
		<p>How many tones did you hear?</p>
		<input type="radio" name="second" value="1">1
		<input type="radio" name="second" value="2">2
		<input type="radio" name="second" value="3">3
		<input type="radio" name="second" value="4">4
		<input type="radio" name="second" value="5">5
		<input type="radio" name="second" value="6">6
		<input type="radio" name="second" value="7">7
		<input type="radio" name="second" value="8">8
		<br>
		<br>
		<button class="btn btn-default btn-lg" type = "submit" value = "Enter">Submit</button>
		</form>
      </div>
    </div>
    
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
  </body>
</html>

<script>
</script>
