Spatial Sound in Virtual Reality

17 Using an AmbiX (or Fuma) recording in Google VR (iOS)

17.1 Setup

The Google VR SDK for iOS contains a set of tools for spatial audio. In order to get started you will need the following:

  • Xcode 7.1 or higher

  • CocoaPods 2323

    1- Create a new single view iOS project in Xcode 2- Close Xcode and open a terminal session and change directory to the newly created folder. (Xcode creates a folder with the name of the project). In that folder, there is a folder with the name of the project and an .xcodeproj file 3- Using vim, create an empty file named Podfile and enter the follwing text:

target 'nameOfProject' do
  pod 'GVRAudioSDK'
Figure 14: Podfile.

4- Make sure Xcode is not open, install the pod running the following command on your terminal: pod install 5 - At this point, you should have a .xcworkspace, a Podfile.lock files and and Pods folder

Figure 15: Pod Folders.

6 - Open the pod created Xcode workspace (not the original .xcodeproj file). 7 - In Xcode, create a new header (.h) file and name it GoogleVRSwift-Bridging-Header (Xcode will add the .h extension) 8- Write the following import statements:

#import "GVRAudioEngine.h"
#import "gvr_audio.h"
#import "gvr_types.h"
#import "gvr_audio_surround.h"
#import "gvr_version.h"
Figure 16: Bridging-Header.

9- Now, we have to tell Xcode that we have a Bridging-Header. Under Build Settings, search for Objective-C Brdiging Header and add the name of your header.

Figure 17: Tell Compiler About the Bridging-Header.

10- Run the project. If Xcode cannot find your header file, you will have to add it to the path: again under Build Settings, search for User Header Search Paths and drag and drop your projects folder. Make it recursive.

Figure 18: Add Header Path to Project.

11- You should be able to instantiate a gvr_audio_create object.

import UIKit

class ViewController: UIViewController {

    let audio_context = gvr_audio_create(Int32(GVR_AUDIO_RENDERING_BINAURAL_HIGH_QUALITY.rawValue))

    override func viewDidLoad() {

        let sound1 = gvr_audio_source_id(gvr_audio_create_sound_object(audio_context, "0.wav"))
        let sound2 = gvr_audio_source_id(gvr_audio_create_soundfield(audio_context, "voice_o1_ambix.wav"))
        gvr_audio_set_sound_object_position(audio_context, sound1, 10, 0, 0)
        gvr_audio_set_sound_volume(audio_context, sound1, 0.5)
        gvr_audio_play_sound(audio_context, sound1, false)

        gvr_audio_play_sound(audio_context, sound2, true)
        // Do any additional setup after loading the view.