Thursday, 9 March 2017

Sounds of Street View

http://www.amplifon.ie/sounds-of-street-view/index.html
"Sounds of Street View" is a multi-sensory tour featuring a unique 3D sound experience where you can explore and navigate through three chosen locations using it like google maps.

The 3D sound for "Sounds of Street View" is create through 5 different key elements which come together to produce the immersive 360 spacial audio which accompanies 360 video. These 5 elements are Placement, Distance, Bearing, Ear Imitation and Inverse Square Law. Below are short videos provided by the project which briefly explain what each aspect is and how they affect the audio. Also provided is the coding used by the project



Coding Template
/**
*  Adds a marker to the Street View map
* @param {Object}  data      settings for this marker, properties include...
*
*  {
*   data.name: String to be used as a name for this marker,
*   data.lat: Lattitude to use for position of this marker
*   data.lng: Longitude to use for position of this marker
*  }
*/
this.addMarker = function(data){

  var marker = new google.maps.Marker({
    map         : obj.panorama,
    title  : data.name,
    position  : new google.maps.LatLng(data.lat, data.lng),
    icon  : 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'
  });
  
  obj.markers.push(marker);

}




Coding Template
define([], function(){
  var rad = function(x) {
    return x * Math.PI / 180;
  };
  
  /**
  * Calculates and returns the distance between 2 google latlng objects
  * @param {google.maps.LatLng}   p1   google LatLng position
  * @param {google.maps.LatLng}   p2   google LatLng position
  * @return {number}   
  */
  return function(p1, p2, metric){
    var R = 6378137,  // Earth’s mean radius in meter
    dLat = rad(p2.lat() - p1.lat()),
    dLong = rad(p2.lng() - p1.lng()),
    a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(rad(p1.lat())) * Math.cos(rad(p2.lat())) * Math.sin(dLong / 2) * Math.sin(dLong / 2),
    c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)),
    d = R * c;  // d = the distance in meter
    return d;    
  }
});









Coding Template
this.updatePan = function(lat, lng, heading){

 // Calculate base angle between the user and the sound
 var xDiff = data.lat - lat,
     yDiff = data.lng - lng,
     angle = Math.atan2(yDiff, xDiff) * (180/Math.PI);

 // Add POV heading offset
 angle -= heading;

 // Convert angle to range between -180 and +180
 if (angle < -180) angle += 360;
 else if (angle > 180) angle -= 360;

 // Calculate panPosition, as a range between -1 and +1
 var panPosition = (angle/90);
 if (Math.abs(panPosition) > 1) {
     var x = Math.abs(panPosition) - 1;
     panPosition = (panPosition > 0) ? 1 - x : -1 + x;
 }

 // Set the new pan poition
 sound.pos3d(panPosition, 1, 1);
}







Coding Template
this.updatePan = function(lat, lng, heading){

 // Calculate base angle between the user and the sound
 var xDiff = data.lat - lat,
     yDiff = data.lng - lng,
     angle = Math.atan2(yDiff, xDiff) * (180/Math.PI);

 // Add POV heading offset
 angle -= heading;

 // Apply lowpass filter *if* the sound is behind us (11,000hz = filter fully open)
 var freq = 11000;
 if (Math.abs(angle) > 90) {
     // User's back is to the sound - progressively apply filter
     freq -= (Math.abs(angle) - 90) * 100;
 }
 
 sound.filter(freq);
}





Coding Template
this.calculateVolume = function(distance){

 // Calculate volume by using Inverse Square Law
 vol = 1 / (distance * distance);
 // Multiply distance volume by amplitude of sound (apply ceiling max of 1)
 vol = Math.min((vol * data.db), 1);

 if (vol < 0.01) {
     if (sound.isPlaying) {
  obj.stopSound();
     }
 } else {
     if (!sound.isPlaying) {
  obj.playSound();
     }
 }

 return vol;
}

Creating your own

"Sounds of Street View" also provides you with the opportunity to create your own version, giving you a step by step guide on how to proceed in creating your own immersive tour.

1.

2.

3.

4.

5.


No comments:

Post a Comment