Q:

Having trouble acquiring the current posts title

I am currently working in wordpress and I have a link that is supposed to play a wav file depending on the title of the post. So if the post title is 'one' then it should play one.wav from the uploads folder. However, the sound file on every post only plays the most current posts title. So if I added a post called two and then a post called one, both posts will play one.wav.
Here's the code:
HTML
<span id="dummy"></span>
<a class="playSound" onclick="playSound();" href="#">
  <i class="fa fa-volume-up"></i>
</a>  

JQuery
function playSound() {
        $.ajax({
            url: 'sound.php',
            data: "getSound",
            type: "GET",
            datatype: "html",
            success: function(data) {
                document.getElementById("dummy").innerHTML= "<embed src=\""+data+"\" hidden=\"true\" autostart=\"true\"loop=\"false\" />";
            }
        });
}

and the PHP
<?php
  require('./wp-blog-header.php');

  if(isset($_GET['getSound'])) {
    $file='wp-content/uploads/2015/wav/' . get_the_title() . '.wav';
    echo $file;  
  }
?>

I assume get_the_title() is the proper call but at this point I am not so sure. I have tried all the other call functions but still no luck. I assume at this point is has to do with the loading of the page and storing the initial posts title but i am just lost at this point.

A:

<?php 
$sound_query = new WP_Query();
    if ($sound_query->have_posts()):
        while ($sound_query->have_posts()):
        $sound_query->the_post();
?>
<script>
function playSound() {
   document.getElementById("dummy").innerHTML= "<embed src='wp-content/uploads/2015/wav/<?php echo get_the_title() ?>.wav' />";
}
</script>

<?php 
    endwhile;
endif;
wp_reset_postdata();
?>

