• Select your platform:

    Platform:

    Ignite Windows with Dolby Audio

    As a Windows® developer, you can now include one of the world’s most advanced, recognizable, and trusted entertainment experiences in your universal applications and web experiences. You're in a unique position to utilize our next-generation Dolby® Audio (supporting Dolby Digital Plus™ technology) which is included in every x86 Windows 10 desktop PC and tablet. This means you simply need to include encoded content in your Windows application or HTML 5 web app, and the Windows 10 operating system will decode that content providing the best enveloping experience for your customer.

     

    A Windows 10 Sample App Project using Dolby technologies is available for download.

    Code Snippet

    																    // Set the picker to include files that can contain Dolby content such as (.3g2, .3gp2, .3gp, .3gpp., m4a., m4v., mp4v, .mp4, .mov, .m2ts, .asf, .wm, .wmv, .wav, .avi, .ac3, .ec3)
    FileOpenPicker filePicker = new FileOpenPicker();
                    filePicker.SuggestedStartLocation = PickerLocationId.VideosLibrary;
                    filePicker.FileTypeFilter.Add(".mp4");
                    filePicker.FileTypeFilter.Add(".wmv");
                    filePicker.ViewMode = PickerViewMode.Thumbnail;
    //Play picked file through native Win 8 playback stack
                    StorageFile localVideo = await filePicker.PickSingleFileAsync();
                    if (localVideo != null)
                    {
                        var stream = await localVideo.OpenAsync(FileAccessMode.Read);
                        VideoSource.SetSource(stream, localVideo.ContentType);
                        rootPage.NotifyUser("You are playing a local video file", NotifyType.StatusMessage);
                    }
    															    
    																    // Set the picker to include files that can contain Dolby content such as (.3g2, .3gp2, .3gp, .3gpp., m4a., m4v., mp4v, .mp4, .mov, .m2ts, .asf, .wm, .wmv, .wav, .avi, .ac3, .ec3)
    		FileOpenPicker^ filePicker = ref new FileOpenPicker();
    		filePicker->SuggestedStartLocation = PickerLocationId::VideosLibrary;
    		filePicker->FileTypeFilter->Append(".mp4");
    		filePicker->FileTypeFilter->Append(".wmv");
    		filePicker->ViewMode = PickerViewMode::Thumbnail;
    //Play picked file through native Win 8 playback stack
    		task<storagefile^>(filePicker->PickSingleFileAsync()).then(
    			[this](StorageFile^ videoFile)
    		{
    			if (videoFile)
    			{
    				localFile = videoFile;
    				task<irandomaccessstream^>(videoFile->OpenAsync(FileAccessMode::Read)).then(
    					[this](IRandomAccessStream^ stream)
    				{
    					if (stream)
    					{
    						VideoSource->SetSource(stream, localFile->ContentType);
    						rootPage->NotifyUser("You are playing a local video file", NotifyType::StatusMessage);
    					}
    				});
    			}
    		});
    	}
    }
    void Scenario1::playButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
    {
    	VideoSource->Play();
    }
    															    
    																    // Set the picker to include files that can contain Dolby content such as (.3g2, .3gp2, .3gp, .3gpp., m4a., m4v., mp4v, .mp4, .mov, .m2ts, .asf, .wm, .wmv, .wav, .avi, .ac3, .ec3)
    var openPicker = new Windows.Storage.Pickers.FileOpenPicker();
           	openPicker.suggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.videosLibrary;
    	openPicker.fileTypeFilter.replaceAll([".mp4", ".wmv"]);
    	openPicker.pickSingleFileAsync().then(function (file) {
    //Play picked file through native Win 8 playback stack
     if (file) {
                   var localVideo = id("VideoSource");
                   localVideo.src = URL.createObjectURL(file, { oneTimeOnly: true });
                   localVideo.play();
               }
     },
    															    
    																    // Set the picker to include files that can contain Dolby content such as (.3g2, .3gp2, .3gp, .3gpp., m4a., m4v., mp4v, .mp4, .mov, .m2ts, .asf, .wm, .wmv, .wav, .avi, .ac3, .ec3)
       Private Async Sub videoFile_Click(sender As Object, e As RoutedEventArgs)
           Dim b As Button = TryCast(sender, Button)
           If b IsNot Nothing Then
               Dim filePicker As New FileOpenPicker()
               filePicker.SuggestedStartLocation = PickerLocationId.VideosLibrary
               filePicker.FileTypeFilter.Add(".mp4")
               filePicker.FileTypeFilter.Add(".wmv")
               filePicker.ViewMode = PickerViewMode.Thumbnail
    //Play picked file through native Win 8 playback stack
               Dim localVideo As StorageFile = Await filePicker.PickSingleFileAsync()
               If localVideo IsNot Nothing Then
                   Dim stream = Await localVideo.OpenAsync(FileAccessMode.Read)
                   VideoSource.SetSource(stream, localVideo.ContentType)
                   rootPage.NotifyUser("You are playing a local video file", NotifyType.StatusMessage)
               End If
           End If
       End Sub
       Private Sub playButton_Click(sender As Object, e As RoutedEventArgs)
           VideoSource.Play()
       End Sub
    															    

    Specs

    Platform Dolby Digital (ac3) Dolby Digital Plus (ec3) 3rd Party Accessible?
    Windows 8
    Windows 10
    Windows 10 Mobile

    Dolby Digital Plus

    Dolby® Digital Plus™, or Enhanced AC-3 (E-AC-3), is an advanced audio codec designed specifically for evolving media. It can be used in Smartphone Apps, Online Streaming Services, PCs, Tablets, Smartphones and Home Theatres. Dolby Digital Plus defines high-fidelity audio. Dolby® Digital Plus™ employs exclusive compression algorithms to efficiently reduce the file size of digital audio programs. This allows easier transmission and storage. It also brings multichannel capability to bandwidth-constrained applications, mobile networks and Internet-delivered entertainment.

    Dolby Audio...Enhanced

    With the Dolby Digital Plus Decoder built into every Windows Machine, Some OEM Partners want to take audio to the next level by including our Dolby Audio Processing solutions. Our solutions are backwards compatible so there is no need to worry about devices that don’t have Dolby Audio Processing. Depending on the flavor of Dolby Audio, developers can provide a better experience to their users. See the table below for more information.

    Code Snippet

    																    // Set the picker to include files that can contain Dolby content such as (.3g2, .3gp2, .3gp, .3gpp., m4a., m4v., mp4v, .mp4, .mov, .m2ts, .asf, .wm, .wmv, .wav, .avi, .ac3, .ec3)
    FileOpenPicker filePicker = new FileOpenPicker();
                    filePicker.SuggestedStartLocation = PickerLocationId.VideosLibrary;
                    filePicker.FileTypeFilter.Add(".mp4");
                    filePicker.FileTypeFilter.Add(".wmv");
                    filePicker.ViewMode = PickerViewMode.Thumbnail;
    //Play picked file through native Win 8 playback stack
                    StorageFile localVideo = await filePicker.PickSingleFileAsync();
                    if (localVideo != null)
                    {
                        var stream = await localVideo.OpenAsync(FileAccessMode.Read);
                        VideoSource.SetSource(stream, localVideo.ContentType);
                        rootPage.NotifyUser("You are playing a local video file", NotifyType.StatusMessage);
                    }
    															    
    																    // Set the picker to include files that can contain Dolby content such as (.3g2, .3gp2, .3gp, .3gpp., m4a., m4v., mp4v, .mp4, .mov, .m2ts, .asf, .wm, .wmv, .wav, .avi, .ac3, .ec3)
    		FileOpenPicker^ filePicker = ref new FileOpenPicker();
    		filePicker->SuggestedStartLocation = PickerLocationId::VideosLibrary;
    		filePicker->FileTypeFilter->Append(".mp4");
    		filePicker->FileTypeFilter->Append(".wmv");
    		filePicker->ViewMode = PickerViewMode::Thumbnail;
    //Play picked file through native Win 8 playback stack
    		task<storagefile^>(filePicker->PickSingleFileAsync()).then(
    			[this](StorageFile^ videoFile)
    		{
    			if (videoFile)
    			{
    				localFile = videoFile;
    				task<irandomaccessstream^>(videoFile->OpenAsync(FileAccessMode::Read)).then(
    					[this](IRandomAccessStream^ stream)
    				{
    					if (stream)
    					{
    						VideoSource->SetSource(stream, localFile->ContentType);
    						rootPage->NotifyUser("You are playing a local video file", NotifyType::StatusMessage);
    					}
    				});
    			}
    		});
    	}
    }
    void Scenario1::playButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
    {
    	VideoSource->Play();
    }
    															    
    																    // Set the picker to include files that can contain Dolby content such as (.3g2, .3gp2, .3gp, .3gpp., m4a., m4v., mp4v, .mp4, .mov, .m2ts, .asf, .wm, .wmv, .wav, .avi, .ac3, .ec3)
    var openPicker = new Windows.Storage.Pickers.FileOpenPicker();
           	openPicker.suggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.videosLibrary;
    	openPicker.fileTypeFilter.replaceAll([".mp4", ".wmv"]);
    	openPicker.pickSingleFileAsync().then(function (file) {
    //Play picked file through native Win 8 playback stack
     if (file) {
                   var localVideo = id("VideoSource");
                   localVideo.src = URL.createObjectURL(file, { oneTimeOnly: true });
                   localVideo.play();
               }
     },
    															    
    																    // Set the picker to include files that can contain Dolby content such as (.3g2, .3gp2, .3gp, .3gpp., m4a., m4v., mp4v, .mp4, .mov, .m2ts, .asf, .wm, .wmv, .wav, .avi, .ac3, .ec3)
       Private Async Sub videoFile_Click(sender As Object, e As RoutedEventArgs)
           Dim b As Button = TryCast(sender, Button)
           If b IsNot Nothing Then
               Dim filePicker As New FileOpenPicker()
               filePicker.SuggestedStartLocation = PickerLocationId.VideosLibrary
               filePicker.FileTypeFilter.Add(".mp4")
               filePicker.FileTypeFilter.Add(".wmv")
               filePicker.ViewMode = PickerViewMode.Thumbnail
    //Play picked file through native Win 8 playback stack
               Dim localVideo As StorageFile = Await filePicker.PickSingleFileAsync()
               If localVideo IsNot Nothing Then
                   Dim stream = Await localVideo.OpenAsync(FileAccessMode.Read)
                   VideoSource.SetSource(stream, localVideo.ContentType)
                   rootPage.NotifyUser("You are playing a local video file", NotifyType.StatusMessage)
               End If
           End If
       End Sub
       Private Sub playButton_Click(sender As Object, e As RoutedEventArgs)
           VideoSource.Play()
       End Sub
    															    

    Specs

    DOLBY FEATURES

    DOLBY AUDIO

    DOLBY AUDIO PREMIUM

    Surround Decoder

    Dialogue Enhancer

    Volume Leveler

    Intelligent Equalizer

    Graphic Equalizer

    Surround Virtualizer (headphone/speaker)

    speaker only

    Audio Optimizer

    Audio Regulator

    Volume Maximizer

    Bass Enhancer

    Virtual Bass

    Media Intelligence

    Endpoint Intelligence

    Multimode Tuning

    Dolby Audio in the Browser

    You may already be familiar with the premium surround sound audio experience that Dolby delivers regularly to feature films in the cinema and home theater. What you may not realize is that the same high-quality experience is also available on the web through the browser. This includes content delivered in Dolby Digital Plus™ as well as Dolby Atmos®.

    Users can now experience the benefits of these audio formats, including improved clarity, loudness, consistency of playback, multichannel surround sound, and the immersive Dolby Atmos experience—all through one of the most common playback methods on the planet: the browser on your laptop or PC. Playback, including Dolby Atmos precise sound rendering from any point in space around or above the listener, can be achieved over any connected headphones* or Dolby Digital Plus or Dolby Atmos enabled receiver connected to the computer via HDMI®.

    This site will get you up to speed on how to get your content prepared and delivered in Dolby® format to the browser. Here you will find sections on content preparation (mixing considerations, for example), encoding options, and tools, as well as sample demonstrations and code to host your content for playback on most popular current HTML 5–capable browsers. Check back often for updated articles, sample code, and tools to help you on your way to delivering the optimal entertainment audio experience to your users.

    read more

    Why Dolby Audio in the Browser?

    With Dolby content delivered to the browser, users can now enjoy the best in-browser entertainment experience available. Dolby Digital Plus has emerged as the primary delivery platform for high-quality connected entertainment in the living room. Many of the world’s leading content streaming services use Dolby to deliver stereo, 5.1, and 7.1 content to entertainment devices such as TVs, gaming consoles, tablets, smartphones, PCs, and smart Blu-ray players.

    With the emergence of high definition video and the increasing resolution and color fidelity in computing displays, the browser visual experience has improved significantly in recent years—yet the audio experience has not—until now. With Dolby Digital Plus encoded content, supporting browsers allow content creators and developers to build web applications and stream content that take advantage of native browser functionality (i.e. without the need for plug-ins such as Flash or Silverlight).

    Dolby Digital Plus is available today in Microsoft Edge (Windows 10 and above), Apple Safari 9 on OS X 10.11 (El Capitan and above), and Apple Safari 9 on iOS 9.3 and above.

    Advantages of Dolby Digital Plus

    Dolby Digital Plus is an end-to-end platform that includes tools for content creators to create stereo and multichannel audio soundtracks. It is also a highly efficient and robust format for delivering content over physical, Internet protocol (IP), and broadcast networks. Content services around the world use Dolby as their preferred format because they know Dolby delivers the best possible entertainment experience to their consumers. Dolby Digital Plus also allows services to greatly simplify their operational infrastructure and workflow. With Dolby Digital Plus, services can create a single audio bitstream and deliver that same bitstream to a multitude of different devices, including TVs, AV Receivers (AVR’s), gaming consoles, smart Blu-ray players, PCs, tablets, and smartphones. Dolby Digital Plus has built-in intelligence to render audio optimally for each device. For example, the decoder will sense whether it is running in a multi-channel home theater system or on a PC with built-in stereo speakers. It will render the output with the volume and dynamic range most appropriate for the situation. Being able to create an audio stream once and deliver it to many different types of devices removes the significant cost of having to create and maintain multiple versions of an asset.

    Volume level variation across a content service catalog is a pervasive issue for streaming services and an annoyance for consumers. Dolby Digital Plus encoding addresses this issue directly.

    Beyond improved dialog clarity and intelligent device-aware loudness management, Dolby Digital Plus supports additional content features, such as support for multiple soundtracks, including different languages, director’s commentary, and descriptive visual services for accessibility. Dolby Digital Plus has also been designed to easily accommodate adaptive bitrate content—so that streamed content can be delivered at the maximum bitrate available to the end user at any given time. In this way content continues to play, even when the network is congested.

    For browser users, Dolby Digital Plus enables a high-quality, immersive entertainment experience that is true to the original artistic intent, featuring crisp sound, clear dialogue, and improved detail. The Dolby Digital Plus decoder automatically optimizes the audio, whether the PC is rendering over stereo endpoints (built-in speakers or headphones) or through a home theater system connected to the PC. For stereo speakers, the dynamic range of the content will be adjusted automatically to accommodate the capabilities of the smaller speakers. The emotion of the content—from quiet conversation to loud action scenes—is retained, drawing the viewer into the story as the artist intended. Dialogue, so crucial to movie and episodic content, is rendered much more intelligibly because the Dolby Digital Plus encoded content contains information that precisely identifies its proper level. If the PC is connected to a surround-sound system, Chrome can deliver the full 5.1 (or 7.1) audio soundtrack to the AVR. With the growing popularity of casting video content from the laptop, this will become a more prevalent use case allowing these users to enjoy a fully immersive experience.

    Browser Support

    The following list of browsers (current as of March 1, 2017) lists each one’s ability to play Dolby Digital Plus or Dolby Atmos encoded streams and files, as reported by the browser vendors. Notice that some browsers use “True” and “False” while others report “No” or “Maybe.” To simplify this detection logic, Dolby has prepared a lightweight JavaScript library (located under the "code" link in the left navigation) you can use to detect browser compatibility. An updated version of the browser compatibility tables is located on the Knowledge Base.

    * Please note that rendering Dolby Atmos for use with headphones requires installation of the Dolby Access application.

      Probably Maybe Supports Dolby Audio
    Microsoft Edge True True
    Chrome 54 False True
    Firefox 47 No False
    Internet Explorer 11 False True
      Probably Maybe Supports Dolby Audio
    Safari 10+ True True
    Safari 8* True True
    Chrome 54 False False
    Firefox 49 True False

      * Safari 8 falsely reports it can play Dolby.

      Probably Maybe Supports Dolby Audio
    Safari 9+ True True
    Chrome 48 Maybe False
      Probably Maybe Supports Dolby Audio
    Amazon Silk True True

    Preparing Audio: Considerations

    In creating a digital entertainment experience to be streamed to the browser, the upstream considerations are largely the same as for creating assets to be delivered via other delivery routes, such as DVD, OTT streaming services, etc. It’s important to always work, where possible, with the original audio and video files so that when you are ready to do your final mix and encode, the amount of post-production distortion is minimized.

    Beyond basic high-quality audio production principles, the main consideration in preparing assets to be optimized for Dolby output is whether you are producing a 2-channel stereo or multichannel (e.g. 5.1, or 7.1/7.2) surround sound experience. If you expect your primary target to be desktop, laptop and mobile devices (and not devices connected to home theater systems), a 2-channel setup has benefits of efficiency and simplicity. Otherwise, if your distribution is likely to be varied you will want to consider a multi-channel mix (that can later be down-mixed).

    Mixing and Encoding: Considerations & Tools

    Once you’ve collected your content and decided on whether you’re going to produce a multi-channel surround production or a 2-channel stereo one, you’ll begin the process of ingesting your media sources. These could include: raw video footage, audio tracks and sound effects, other video clips, etc. Typically, these will be imported into a non-linear editing system, such as Adobe Premiere, Final Cut Pro, or any of a number of editing systems.

    In your editing system, you will need to ensure each sound channel is optimized to play back in the right position at the appropriate levels. For finer-grained control of spatial audio, tools like Adobe Audition and Avid ProTools provide great controls that allow you to vary sound direction and characteristics over time—so, for example, you could have a sound start in the front-left and move rapidly around the room clockwise and then fade out. The sky is the limit using these sophisticated audio processing tools. Rest assured that once you’ve got your final mix playing perfectly in your studio, that the Dolby encoding process will preserve the crucial aspects of your production for perfect playback on any supporting device. Please see this Dolby video for a simple illustration of mixing and encoding a simple short video with audio from multiple sources. For a more extensive demo that uses both Premiere and Audition, see this demo from Adobe. For a more in-depth overview of production principles for preparing a high quality Dolby Audio accompaniment to your video, see the Dolby Made for Web Sound Production Guide.

    Encoding Audio to Dolby Digital Plus

    If you’re already working with Adobe Premiere and Audition, you have a complete Dolby Audio encoding solution in your product. Simply export your video in h.264 for video and then select Dolby|Dolby Digital Plus as the audio encoding codec. Reasonable default parameters are provided and you can adjust these as fits your audio profile. If, on the other hand, your video production files are not mixed in Premiere, you can alternatively use any number of available Dolby Audio encoding solutions. To get started with a small sample file, try out our simple web-based encoder on this site.For larger files, sign up for an encoding.com account and select the video and Dolby Digital Plus parameters you desire.

    Transport Formats

    The most common format you’ll encounter for your video files will be MP4—with an H.264 video track and a Dolby Digital Plus audio track—along with a fallback .mp4 file with an AAC (or other prolific audio codec) track for audio, to play in the event the browser does not yet support Dolby Digital Plus. See the Code section of this site for information on how to detect and play the video file you desire.

    For a more robust setup to support high quality assets to a large number of users with varying bandwidth capabilities, you will want to consider delivering you video and audio via a streaming format, such as MPEG-DASH or HLS, both of which support Dolby Digital Plus audio tracks. There are a number of tools which will take your baseline video and audio files and convert them to these formats. Encoding.com provides this as one of the output formats. Other stand-alone tools include both open source and commercial tools, including mp4box, Elemental Stream, and others. Packaging your video and audio tracks in these streaming formats provides a more efficient means to deliver your video over the web. Moreover, they can be configured to play your media in adaptive bitrate, so that depending on the bandwith available to the consumer, the best video/audio tracks will be served, to balance quality with playback capability.

    Get the code

    Websites will now be able to selectively support Dolby Audio as a premium sound experience. Websites that want to use Dolby should feature detect on the format and be prepared to stream alternative audio formats on systems that don’t support Dolby Audio.

    Step 1: Add this script to your HTML file

    1. <script type="text/javascript"
    2. src="https://s3-us-west-1.amazonaws.com/dolbydeveloper/1.1.0/js/dolby.min.js"></script>

    Step 2: Add the Method

    Use this method in your code to check for Dolby Audio Support. This method will return TRUE if Dolby Digital Plus is supported. Then you can enable higher quality sound and features that Dolby provides by delivering audio and video assets encoded in Dolby Digital Plus.

    Dolby.checkDDPlus()

    Step 3: Playback: HTML5 and Javascript

    Once you’ve got your video and/or audio assets prepared (mixed, encoded, and formatted), all that remains is serving up the media files on the web. Modern web browsers supporting HTML5 can handle most of the work for you through a combination of HTML tags (the <video> and <audio> tags) and JavaScript.

    The most basic playback of a video file containing a Dolby Digital Plus (DD+) audio track, simply uses the video element to point to the encoded file. The browser does the rest, providing a simple player and performing the decoding.

    Using the <video> and <audio> elements with their default behavior alone is just the beginning. You can use JavaScript and tag attributes to customize the player as you desire, with custom start/pause/playback speed buttons, alternative video sizes, and many other attributes. See this article from Microsoft on using JavaScript to customize your video playback experience.

    HTML Audio/Video DOM Reference HTML Video JS Control

    Web Audio API

    If you’ve prepared your audio assets in DD+ (and typically a fallback encoding), you can use these same audio files to create interactive experiences using the WebAudio API. Browsers running on systems that support DD+ (MS Windows 10 and above; Mac OS 10.11 and above) can decode DD+ audio streams in the same way they decode other audio formats. Use AudioContext.DecodeAudioData(). You can use mono, stereo, or multi-channel inputs. Once you have the audio ingested you can further manipulate it using the WebAudio API features, including the PannerNode to place your sounds dynamically based on user input or desired events. See the re.flow demo and blog post series which showcases blending 3D graphics objects in WebGL with 3D panning in WebAudio to create an immersive interactive audio/video experience using Dolby Digital Plus.

    View Reflow Demo Flow.GL/Blog

    Now Playing: Dolby Atmos
    on XBOX and PC

    Game developers are now able to deliver Dolby Atmos audio in XBOX One and PC games, bringing three-dimensional audio, including height and depth (with headphones), to the gaming experience.

    Dolby Atmos helps you create a realistic game-play environment that lets you hear every window smash, feel every explosion, and experience every wipeout as if they're really happening. Atmos provides the strategic advantage of being able to pinpoint enemies and offscreen obstacles. You're not just playing the game—you feel like you're in it.

    Dolby Atmos in Microsoft Platform Games

    Dolby Atmos is enabled on the XBOX, Windows desktop (Win32) applications as well as Universal Windows Platform (UWP) applications by leveraging Microsoft's Spatial Audio APIs. This allows developers to create dynamic audio objects that move throughout the soundscape using Microsoft's ISpatialAudioClient.

    In general, developers using ISpatialAudioClient will do the following to add dynamic audio objects:

    • Create static and/or dynamic audio objects.
    • Feed each object’s audio buffer each frame so the system can render it.
    • Update dynamic objects’ 3D positions on demand – as frequently (or infrequently) as the app desires.

    For more information on using Dolby Atmos with Microsoft's Spatial Audio APIs, see MSDN's entry on Spatial Sound.

    Dolby Audio for Playstation and PC

    Dolby Audio puts gamers right in the middle of the action, providing a competitive advantage and making the experience more exciting and real. Featured in today’s top games, Dolby Audio enhances the impact of the dazzling graphics with striking surround sound that makes players feel as if they are actually inside the game.

    Dolby Audio helps you create and deliver stunning multichannel (5.1, 7.1) sound PlayStation and PCs running Windows 7 or Windows 8. Dolby encoding gives active sound positioning that follows the screen action for a listening experience that rivals Hollywood’s blockbusters.

    Console Support

        
    Dolby Atmos
    Dolby Digital Plus*  *  
    Dolby True HD* *
    Dolby Digital
    Dolby Pro Logic II
    * For linear content only

    Middleware Providers Supporting Dolby Atmos

    The following middleware providers offer support for Dolby Atmos:

    Bespoke Solutions

    For developers who want to incorporate object-based audio into their own audio engine, there are a few fundamental systems that will need to be updated.

    • Panning - Up until now, audio engines have been taking only the x and y coordinates from a 3D game’s output when tracking position of an object. Now with Dolby Atmos, one needs to incorporate the z axis into the panning algorithms, both runtime 3D positional panning as well as any offline panning tools for content creators.
    • Object management - As discussed above, Dolby Atmos consists of both dynamic and static objects (Bed), with a total maximum number of 32. It will be up to the audio engine to decide what sound will be assigned to either a dynamic object or mixed into the bed objects. Those objects will then be passed to the platform’s 3D audio API for packaging into the Dolby Atmos bitstream. This is because every game and engine is unique, and prioritization rules that work for one may not work for another. Also, many engines and middleware already have a robust prioritization and management system where object-audio management can easily be added.
    • Linear content ingestion - Content that has already been mixed in Dolby Atmos will have a unique file format that will include PCM audio data along with descriptive metadata. This could be the soundtrack for a cut-scene, music, or a rich ambience track. This file format will need to be properly read into the audio engine in order to pass it through to the system and eventually to the platform’s 3D audio API.

    Creating Games with Dolby Technology

    It's simple and affordable to create games with Dolby technology. The following steps describe the process.

    • Contact the Dolby Games group
      First, drop us a note by contacting us. Whether you’re working on an upcoming game title, developing your next-generation in-house audio engine, or planning a new middleware product for developers, we offer custom support to suit your needs. If you are developing software for the PlayStation 4, please refer to information at Sony's PlayStation Developer Network. For Xbox One related documentation contact XBOX Live Developer Portal and for support contact XBOX Live Forums. The Xbox team has information particular to Dolby Atmos and Dolby Digital Plus for the Xbox consoles. For Wii products, take a look at the Dolby Pro Logic II support built into Nintendo's AX API.
    • Get the logo
      Nearly every major game publisher has already executed our Trademark Agreement (TMA). This agreement allows publishers to use the Dolby Laboratories logo and associated trademarks. It's always a good idea to contact us to make sure your publisher is signed up and ready to proceed.
    • Submit your game for Dolby review
      For quality assurance purposes, Dolby recommends that developers/publishers submit one copy of each of their products that use our technologies, so we can ensure that our technologies have been implemented in the best possible way before a title ships. Our quality assurance program can provide valuable feedback on the quality of the sound in your game title. If you are interested in receiving an evaluation from our experienced testing department, let us know. Also, if possible, any packaging, artwork, or instruction manual content that mention Dolby technologies should be submitted to Dolby for review before a product ships. For more information on Dolby Game Certification criteria, please review the Dolby Game Certification Entry (Login Required) on the Dolby Developer Knowledge Base.

    FAQ and Knowledgebase

    For FAQ information, please see the Dolby Developer Knowledgebase (Login Required)

    Dolby Audio Format for Android

    Dolby has worked with many OEMs to integrate Dolby Audio supporting Dolby Digital Plus into phones & tablets. As a developer you can deliver Dolby premium quality content by including the content into your Android projects. Benefits will include a clear and consistent playback of audio allowing your customers to get the best experience. Take a look below for more information to find out which devices have integrated Dolby Audio.

     

     

    Quick Start Guide

    An overview of two Android media classes that developers can use to add Dolby Digital Plus playback in their applications, and demonstrates the process with code snippets.

    ddp_android_playback_guide.pdf 0.795 mb
    View Guide

    Code Snippet

    																    //Create a MediaExtractor instance, and select the audio stream according to the MIME type of Dolby Digital Plus.
    
    public final static String EAC3_AUDIO = "audio/eac3"; mExtractor = new MediaExtractor(); 
     
    for (int i = 0; i < numTracks; ++i) {
         MediaFormat format = mExtractor.getTrackFormat(i);
         String mime_type = format.getString(MediaFormat.KEY_MIME);
              if (mime_type.equals(EAC3_AUDIO)) { //eac3 stands for Dolby Digital Plus.
                   mExtractor.selectTrack(i);
                   mFormatAudio = format;
                   mMimeTypeAudio = mime_type;
              Log.d(TAG, "selected audio track with type: " + mime_type);
              }
         ...... 
    }
    
    //Create and configure a MediaCodec instance
    mCodecAudio = MediaCodec.createDecoderByType(mMimeTypeAudio);
    mCodecAudio.configure(mFormatAudio, null, null, 0);
     
    //Start the MediaCodec instance to decode the audio stream.
    mCodecAudio.start();
     
    //Create and start an AudioTrack instance to render the decoded PCM audio data.
    mTrack = new AudioTrack(AudioManager.STREAM_MUSIC, sampleRateHz, channelConfig, AudioFormat.ENCODING_PCM_16BIT, bufferSize*2, AudioTrack.MODE_STREAM, 0);
    mTrack.play();
    mTrack.write(pcm_data, 0, pcm_data.length);
     
    //Release the instances of MediaExtractor, MediaCodec, and AudioTrack when the playback stops.
    if (mCodecAudio != null) {
         mCodecAudio.stop();
         mCodecAudio.release();
         mCodecAudio = null;
         }
     
    if (mExtractor != null) {
         mExtractor.release();
         mExtractor = null;
         }
     
    if (null != mTrack) {
         mTrack.stop();
         mTrack.flush();
         mTrack.release();
         mTrack = null;
         }
    															    

    Specs

    Platform Dolby Digital(ac3) Dolby Digital Plus (ec3)
    HTC 10
    Lenovo Phab 2
    LG G5

    Dolby Digital Plus

    Dolby® Digital Plus™, or Enhanced AC-3 (E-AC-3), is an advanced audio codec designed specifically for evolving media. It can be used in Smartphone Apps, Online Streaming Services, PCs, Tablets, Smartphones and Home Theaters. Dolby Digital Plus defines high-fidelity audio. Dolby® Digital Plus™ employs exclusive compression algorithms to efficiently reduce the file size of digital audio programs. This allows easier transmission and storage. It also brings multichannel capability to bandwidth-constrained applications, mobile networks and Internet-delivered entertainment.

    Sample Project

    Dolby Audio Format Sample Project

    ddp_android_playback.zip 0.796 mb
    Download

    Dolby Audio API

    As an Android™ Developer, you can take advantage of Dolby® Digital Plus™, which is built into many Android™ devices out in the market. This means your Android™ Applications and Games can have amazing immersive sound by integrating the Dolby® Audio API for Android™

    The impact on music, movies, and games is noticeable and immediate. (Try this Demo)

    Dolby is introducing the Dolby® Audio API for Android™, which only takes 15 minutes to integrate, It's also 100% free!

    Benefits include:

    • Volume Leveling: maintains constant volume across all content and applications.
    • Surround Virtualizer: creates a surround sound experience.
    • Audio Optimizer: gives you natural and louder, distortion-free sound.
    • Dolby Digital Pass-Through: allows direct home theater connections for a full multichannel experience.
    • So it's time to stand out from the crowd. Download the Dolby® Audio API for Android™ today!

     

    Quick Start Guide

    To view the Android audio API quick start guide, click the direct link below.

    Dolby Audio API Quick Start Guide  
    View the Guide

    API Package

    Dolby® Audio API for Android™

    Dolby Audio API 2.3 mb
    Download API

    Code Snippet

    																    // This is for DEMO purposes only, for a more in-depth use of the API make sure to download the Dolby Audio API Package for documentation and sample code
    import android.app.Activity;
    import android.media.MediaPlayer;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.Toast;
    import com.dolby.dap.DolbyAudioProcessing;
    import com.dolby.dap.OnDolbyAudioProcessingEventListener;
    import com.dolby.dap.DolbyAudioProcessing.PROFILE;
    public class MainActivity
    extends Activity implements MediaPlayer.OnCompletionListener, OnDolbyAudioProcessingEventListener
    {
    Button btnPlay;
    MediaPlayer mPlayer;
    DolbyAudioProcessing mDolbyAudioProcessing;
    @Override
    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      btnPlay = new Button(this);
      btnPlay.setText("Play");
      btnPlay.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
          if(mPlayer == null) {
            try {
              mPlayer = MediaPlayer.create(
                MainActivity.this,
                R.raw.audio_dolby_living_room);
              mPlayer.start();
            }
            catch (Exception e) {
              e.printStackTrace();
            }
          }
          else {
            mPlayer.stop();
            mPlayer.release();
            mPlayer = null;
          }
        }
      });
    setContentView(btnPlay);
    mDolbyAudioProcessing = DolbyAudioProcessing.getDolbyAudioProcessing(this, DolbyAudioProcessing.PROFILE.GAME, this);
    if (mDolbyAudioProcessing == null){
    	Toast.makeText(this, "Dolby isn't available on this device", Toast.LENGTH_SHORT).show();
    	finish();
    	return;
    }
    }
    @Override
    public void onDestroy() {
      super.onDestroy();
      if(mPlayer != null) {
        mPlayer.release();
      }
    this.releaseDolbyAudioProcessing();
    }
    //OnCompletionListener Methods
    @Override
    public void onCompletion(MediaPlayer mp) {
      mPlayer.release();
      mPlayer = null;
    }
    @Override
    public void onDolbyAudioProcessingClientConnected() {
    }
    @Override
    public void onDolbyAudioProcessingClientDisconnected(){
    }
    @Override
    public void onDolbyAudioProcessingProfileSelected(PROFILE arg0){
    }
    @Override
    public void onDolbyAudioProcessingEnabled(boolean arg0) {
    	// TODO Auto-generated method stub
    }
    public void releaseDolbyAudioProcessing(){
    	if (mDolbyAudioProcessing != null) {
    		mDolbyAudioProcessing.release();
    		mDolbyAudioProcessing = null;
    	}
    	}
    }
    															    
    																    // Dolby Audio Plug-in for Unity 3D available for download in the frameworks tab.
    using UnityEngine;
    using System.Collections;
    using System.Runtime.InteropServices; //Allows us to use DLLImport
    public class DolbyController : MonoBehaviour
    {
      #if UNITY_ANDROID && !UNITY_EDITOR
      [DllImport("DSPlugin")]
      public static extern bool isAvailable();
      [DllImport("DSJavaPlugin")]
      public static extern int initialize();
      [DllImport("DSJavaPlugin")]
      public static extern int setProfile(int profileid);
      [DllImport("DSJavaPlugin")]
      public static extern int suspendSession();
      [DllImport("DSJavaPlugin")]
      public static extern int restartSession();
      [DllImport("DSJavaPlugin")]
      public static extern void release();
      void Start() {
        if (isAvailable()) {
          InitDolby(10);
        }
      }
      void InitDolby(int limit) {
        if (initialize() > -1) {
          setProfile(2); /* Set Profile to "Game" */
        } else if (limit > 0) {
          limit --;
          StartCoroutine(Delay(limit));
        }
      }
      IEnumerator Delay(int limit){
        // Wait 100ms to make sure Dolby service is enabled
        yield return new WaitForSeconds(0.1f);
        InitDolby(limit);
      }
      void OnApplicationPause(bool pauseStatus) {
        if (!pauseStatus) return;
        suspendSession();
      }
      void OnApplicationFocus(bool focusStatus) {
        if (!focusStatus) return;
        restartSession();
      }
      void OnApplicationQuit() {
        release();
      }
      #endif
    }
    															    
    																    // Dolby Audio Plug-in for AIR available for download in the frameworks tab.
    try{
    if (DolbyAudio.isSupported())
    {
    DolbyAudio.create();
    DolbyAudio.audio.setDolbyAudioEnabled(true);
    textDebug("Dolby audio enabled.");
    } else {
    textDebug("Dolby Audio Processing not available on this device.");
    }
    }catch(e:Error){
    textDebug("Error trying dolby audio"+e.toString());
    }
    															    
    																    // Dolby Audio Plug-in for Cordova available for download in the frameworks tab.
    <script type="text/javascript">
    
        var onDeviceReady = function () {
    
            //initialize Dolby Audio Processing
            dolby.dap.initialize(dolby.DapProfile.GAME, onSuccess, onFail);
        }
    
        function onSuccess() {
        }
    
        function onFail(err) {
        }
    
    </script>
    															    

    Specs

      Format Support Post Processing Developer Access
    Platform Dolby Digital(ac3) Dolby Digital Plus (ec3) Dolby Audio Processing Dolby Audio API
    Lenovo A7000 w/ Atmos
    HTC One M9 (2015)
    Samsung Galaxy S4
    Samsung Galaxy Tab 3 8”

    Dolby Digital Plus

    Dolby® Digital Plus™, or Enhanced AC-3 (E-AC-3), is an advanced audio codec designed specifically for evolving media. It can be used in Smartphone Apps, Online Streaming Services, PCs, Tablets, Smartphones and Home Theaters. Dolby Digital Plus defines high-fidelity audio. Dolby® Digital Plus™ employs exclusive compression algorithms to efficiently reduce the file size of digital audio programs. This allows easier transmission and storage. It also brings multichannel capability to bandwidth-constrained applications, mobile networks and Internet-delivered entertainment.

    Fire up Dolby Audio

    As an Amazon App Developer, you now have access to Dolby® Audio, which is built into every Kindle Fire™ HD & HDX product. This means you can now include one of the world’s most advanced, recognizable, and trusted entertainment experiences directly in your application.

    Dolby is redefining the way your customers enjoy entertainment. Dolby® Audio produces dynamic surround sound, while simultaneously making overall audio more consistent. The impact on music, movies, and games is noticeable and immediate. (Try this Demo )

    Dolby is introducing the Dolby® Audio API (Unity, Marmalade Plug-ins also available), which only takes 15 minutes to integrate, It's also 100% free!

    Benefits include:

    • Volume Leveling: maintains constant volume across all content and applications.
    • Surround Virtualizer: creates a surround sound experience.
    • Audio Optimizer: gives you natural and louder, distortion-free sound.
    • Dolby Digital Pass-Through: allows direct home theater connections for a full multichannel experience.

    Download the Dolby® Audio API today and make your Kindle Fire™ Game sound better than ever.  

    Quick Start Guide

    To view the Kindle Fire API quick start guide, click the direct link below.

    Dolby Audio API Quick Start Guide  
    View the Guide

    API Package

    Dolby® Audio API for Android™

    Dolby Audio API 2.3 mb
    Download API

    Code Snippet

    																    // This is for DEMO purposes only, for a more in-depth use of the API make sure to download the Dolby Audio API Package for documentation and sample code
    import android.app.Activity;
    import android.media.MediaPlayer;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.Toast;
    import com.dolby.dap.DolbyAudioProcessing;
    import com.dolby.dap.OnDolbyAudioProcessingEventListener;
    import com.dolby.dap.DolbyAudioProcessing.PROFILE;
    public class MainActivity
    extends Activity implements MediaPlayer.OnCompletionListener, OnDolbyAudioProcessingEventListener
    {
    Button btnPlay;
    MediaPlayer mPlayer;
    DolbyAudioProcessing mDolbyAudioProcessing;
    @Override
    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      btnPlay = new Button(this);
      btnPlay.setText("Play");
      btnPlay.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
          if(mPlayer == null) {
            try {
              mPlayer = MediaPlayer.create(
                MainActivity.this,
                R.raw.audio_dolby_living_room);
              mPlayer.start();
            }
            catch (Exception e) {
              e.printStackTrace();
            }
          }
          else {
            mPlayer.stop();
            mPlayer.release();
            mPlayer = null;
          }
        }
      });
    setContentView(btnPlay);
    mDolbyAudioProcessing = DolbyAudioProcessing.getDolbyAudioProcessing(this, DolbyAudioProcessing.PROFILE.GAME, this);
    if (mDolbyAudioProcessing == null){
    	Toast.makeText(this, "Dolby isn't available on this device", Toast.LENGTH_SHORT).show();
    	finish();
    	return;
    }
    }
    @Override
    public void onDestroy() {
      super.onDestroy();
      if(mPlayer != null) {
        mPlayer.release();
      }
    this.releaseDolbyAudioProcessing();
    }
    //OnCompletionListener Methods
    @Override
    public void onCompletion(MediaPlayer mp) {
      mPlayer.release();
      mPlayer = null;
    }
    @Override
    public void onDolbyAudioProcessingClientConnected() {
    }
    @Override
    public void onDolbyAudioProcessingClientDisconnected(){
    }
    @Override
    public void onDolbyAudioProcessingProfileSelected(PROFILE arg0){
    }
    @Override
    public void onDolbyAudioProcessingEnabled(boolean arg0) {
    	// TODO Auto-generated method stub
    }
    public void releaseDolbyAudioProcessing(){
    	if (mDolbyAudioProcessing != null) {
    		mDolbyAudioProcessing.release();
    		mDolbyAudioProcessing = null;
    	}
    	}
    }
    															    
    																    // Dolby Audio Plug-in for Unity 3D available for download in the frameworks tab.
    using UnityEngine;
    using System.Collections;
    using System.Runtime.InteropServices; //Allows us to use DLLImport
    public class DolbyController : MonoBehaviour
    {
      #if UNITY_ANDROID && !UNITY_EDITOR
      [DllImport("DSPlugin")]
      public static extern bool isAvailable();
      [DllImport("DSJavaPlugin")]
      public static extern int initialize();
      [DllImport("DSJavaPlugin")]
      public static extern int setProfile(int profileid);
      [DllImport("DSJavaPlugin")]
      public static extern int suspendSession();
      [DllImport("DSJavaPlugin")]
      public static extern int restartSession();
      [DllImport("DSJavaPlugin")]
      public static extern void release();
      void Start() {
        if (isAvailable()) {
          InitDolby(10);
        }
      }
      void InitDolby(int limit) {
        if (initialize() > -1) {
          setProfile(2); /* Set Profile to "Game" */
        } else if (limit > 0) {
          limit --;
          StartCoroutine(Delay(limit));
        }
      }
      IEnumerator Delay(int limit){
        // Wait 100ms to make sure Dolby service is enabled
        yield return new WaitForSeconds(0.1f);
        InitDolby(limit);
      }
      void OnApplicationPause(bool pauseStatus) {
        if (!pauseStatus) return;
        suspendSession();
      }
      void OnApplicationFocus(bool focusStatus) {
        if (!focusStatus) return;
        restartSession();
      }
      void OnApplicationQuit() {
        release();
      }
      #endif
    }
    															    
    																    // Dolby Audio Plug-in for AIR available for download in the frameworks tab.
    try{
    if (DolbyAudio.isSupported())
    {
    DolbyAudio.create();
    DolbyAudio.audio.setDolbyAudioEnabled(true);
    textDebug("Dolby audio enabled.");
    } else {
    textDebug("Dolby Audio Processing not available on this device.");
    }
    }catch(e:Error){
    textDebug("Error trying dolby audio"+e.toString());
    }
    															    
    																    // Dolby Audio Plug-in for Cordova available for download in the frameworks tab.
    <script type="text/javascript">
     
        var onDeviceReady = function () {
     
            //initialize Dolby Audio Processing
            dolby.dap.initialize(dolby.DapProfile.GAME, onSuccess, onFail);
        }
     
        function onSuccess() {
        }
     
        function onFail(err) {
        }
     
    </script>
    															    

    Specs

      Format Support Post Processing Developer Access
    Platform Dolby Digital(ac3) Dolby Digital Plus (ec3) Dolby Audio Processing Dolby Audio API
    Amazon Fire HD Series
    Amazon Fire HDX Series
    Amazon Fire TV & Stick

    Dolby Digital Plus

    Dolby® Digital Plus™, or Enhanced AC-3 (E-AC-3), is an advanced audio codec designed specifically for evolving media. It can be used in Smartphone Apps, Online Streaming Services, PCs, Tablets, Smartphones and Home Theaters. Dolby Digital Plus defines high-fidelity audio. Dolby® Digital Plus™ employs exclusive compression algorithms to efficiently reduce the file size of digital audio programs. This allows easier transmission and storage. It also brings multichannel capability to bandwidth-constrained applications, mobile networks and Internet-delivered entertainment.

    Sample Project

    Dolby® Audio API for Android™ Sample App

    DolbyAudioExample.apk.zip 2.3 mb
    DOWNLOAD

    Perfect Audio —? No Matter How You Plug in

    Dolby Developer has come up with some cool solutions for App & Game Developers. We've introduced the Dolby Audio API which is a Java solution and works naturally with native Android Developers, but we understand that developers want choice when it comes to cross-platform tools. That's why we're including some plug-ins for you to use.

     

    We’re adding new frameworks constantly so if you don't see yours , let us know , or check back soon.

    iOS

    Originally introduced in iOS 9.3 and now in iOS 10, Dolby Audio is supported on millions of iOS devices, including the new iPhone 7 and iPhone 7 Plus. Dolby Digital Plus (also known as E-AC-3) and Dolby Digital (AC-3), two of the audio formats that enable the Dolby Audio experience, are natively supported data types in Core Audio, the foundational audio framework for all Apple platforms. Dolby Audio decoding is also available to all third-party applications. This means that these audio formats are supported throughout the operating system and in all the high-level media frameworks such as AVFoundation or Audio Toolbox. Playback of Dolby Audio in AVPlayer, for example, is as simple as passing a file with a Dolby Digital Plus soundtrack, and the system handles the rest.

    Code Snippet

    																    // Sample code using the AVPlayer Class
    //
    //
    #import "DLBAVPlayer.h"
    
    @implementation DLBAVPlayer
    
    -(id) initWithPath:(NSString *)path{
        
        if (!(self=[super init])) return nil;
        if (!path) {
            NSLog(@"*** Error *** DLBAVPlayer init path is nil\n");
            return nil;
        }
    /*
        //NSURL *movieURL = [[NSBundle mainBundle] URLForResource:@"2ch_dd_audio" withExtension:@"mp4"];
        NSURL *movieURL = [NSURL fileURLWithPath:path];
        AVAsset *movieAsset = [AVURLAsset URLAssetWithURL:movieURL options:nil];
        AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:movieAsset];
        AVPlayer *player = [AVPlayer playerWithPlayerItem:playerItem];
        AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player];
        playerLayer.frame = self.view.layer.bounds;
        
        [self.view.layer addSublayer:playerLayer];
        [player play];
    */    
        return self;
        
    }
    
    @end
    															    
    																    #import "DLBAVAudioPlayer.h"
    
    AVAudioPlayer *audioplayer;
    
    @implementation DLBAVAudioPlayer
    
    -(id) initWithAudio:(NSString *)path{
        
        if (!path) {
            NSLog(@"*** Error *** DLBAVAudioPlayer init path is nil\n");
            return nil;
            
        }
        
        mError = 0;
        NSError *error = nil;
        
        audioplayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:nil];
        
        AVAudioSession *session = [AVAudioSession sharedInstance];
        NSUInteger outputs = session.maximumOutputNumberOfChannels;        //query the number of channels the hardware has
        //NSLog(@"output channel:%lu", (unsigned long)outputs);
        
        NSUInteger source = audioplayer.numberOfChannels;       //query the number of channels in source audio
        //NSLog(@"source channel:%lu", (unsigned long)source);
        
        if (outputs == 2 || outputs == 1) {     // 2 for steoro, 1 for mono
            [session setPreferredOutputNumberOfChannels:outputs error:&error];
        }
        else if (outputs == 6) {
            if (source < 6) {
                [session setPreferredOutputNumberOfChannels:source error:&error];
            } else {
                [session setPreferredOutputNumberOfChannels:outputs error:&error];
            }
        }
        else if (outputs == 8) {
            if (source < 8) {
                [session setPreferredOutputNumberOfChannels:source error:&error];
            } else {
                [session setPreferredOutputNumberOfChannels:outputs error:&error];
            }
        }
        else {
            [session setPreferredOutputNumberOfChannels:outputs error:&error];
        }
        
        bool success = [session setActive:YES error:&error];
        NSAssert(success, @"Error setting AVAudioSession active! %@", [error localizedDescription]);
        
        //NSUInteger input = session.inputNumberOfChannels;
        //NSLog(@"output channel:%lu", (unsigned long)input);   //always return 0
    
        [audioplayer play];
        
        mStarted = YES;
        mEnd = NO;
        
        return self;
        
    }
    
    -(void)audioPlayerDidFinishPlaying:(AVAudioPlayer*)player successfully:(BOOL)flag {
        mEnd = YES;
    }
    
    -(int8_t)getPlayingStatus{
        
        if (mError < 0) {
            return mError;
        }
        
        return mStarted;
    }
    
    -(Float32)getCurrentPlaybackPos{
        
        if (!mStarted)
            return 0.0;
        
        if (mEnd) {
            return [self getFileDuration];
        }
        
        return audioplayer.currentTime;
        
    }
    
    -(Float32)getFileDuration{
        
        return audioplayer.duration;
    }
    
    -(void) stopPlayback{
        
        mStarted = NO;
        mEnd = YES;
        NSLog(@"stopPlayback");
        [audioplayer stop];
    
    }
    
    @end
    															    
    																    #import "DLBAUGraphPlayer.h"
    
    @implementation DLBAUGraphPlayer
    
    
    OSStatus checkError(OSStatus err, const char * msg)
    {
        if (noErr == err)
            return noErr;
        
        char errStr[30]={0};
        
        *(UInt32 *)(errStr + 1) = CFSwapInt32HostToBig(err);
        
        if (isprint(errStr[1]) && isprint(errStr[2]) && isprint(errStr[3]) && isprint(errStr[4]))
        {
            errStr[0]=errStr[5]='\'';
            errStr[6]='\0';
        }
        else {
            sprintf(errStr,"%d",(int)err);
        }
        
        NSLog(@"*** Error *** %s, (%s) \n",msg,errStr);
        
        return err;
    }
    
    static OSStatus renderNotification(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData)
    {
        
        if (*ioActionFlags == kAudioUnitRenderAction_PostRender) {
            
            AudioBufferDataPtr data = (AudioBufferDataPtr)inRefCon;
            //DLBAUGraphPlayer *player = (__bridge DLBAUGraphPlayer *)data->player;
            
            data->frameNum += inNumberFrames;
    
        }
    
        
        return noErr;
    }
    
    -(id)createDLBAUGraph
    {
        //Create AUGraph
        if (noErr != checkError(NewAUGraph(&mGraph), "NewAUGraph failed") )
            return nil;
        
        //Create description for output
        AudioComponentDescription outputDesc = {0};
        outputDesc.componentType = kAudioUnitType_Output;
        outputDesc.componentSubType = kAudioUnitSubType_RemoteIO;
        outputDesc.componentManufacturer = kAudioUnitManufacturer_Apple;
        
        //Create description for file player
        AudioComponentDescription playerDesc = {0};
        playerDesc.componentType = kAudioUnitType_Generator;
        playerDesc.componentSubType = kAudioUnitSubType_AudioFilePlayer;
        playerDesc.componentManufacturer = kAudioUnitManufacturer_Apple;
        
        //Add output node
        if (noErr != checkError(AUGraphAddNode(mGraph, &outputDesc, &mOutputNode), "AUGraphAddNode failed, adding output node"))
            return nil;
        
        //Add player node
        
        if (noErr != checkError(AUGraphAddNode(mGraph, &playerDesc, &mPlayerNode), "AUGraphAddNode failde, add player node"))
            return nil;
        
        //Open the graph
        if (noErr != checkError(AUGraphOpen(mGraph), "AUGraphOpen failde"))
            return nil;
        
        //Get the AudioUnit object
        if (noErr != checkError(AUGraphNodeInfo(mGraph, mPlayerNode, NULL, &mPlayerAU), "AUGraphNodeInfo failed"))
            return nil;
        
        //Connect player node to output
        if (noErr != checkError(AUGraphConnectNodeInput(mGraph, mPlayerNode, 0, mOutputNode, 0),"AUGraphConnectNodeInput failed"))
            return nil;
        
        //Add render notification after the render operation is complete
        AUGraphAddRenderNotify(mGraph, renderNotification, &mAudioData);
        
        //Init the graph
        if (noErr != checkError(AUGraphInitialize(mGraph),"AUGraphInitialize failed"))
            return nil;
        
        
        return self;
    }
    
    -(int8_t)startPlayback:(NSString *)path{
        
        //Open the audio file
        if (noErr != checkError(AudioFileOpenURL((__bridge CFURLRef)[NSURL fileURLWithPath:path], kAudioFileReadPermission, 0, &mAudioFile),"AudioFileOpenURL failed"))
            return -1;
        
        
        UInt32 nSize = sizeof(mAudioDataFormat);
        if (noErr != checkError(AudioFileGetProperty(mAudioFile, kAudioFilePropertyDataFormat, &nSize, &mAudioDataFormat), "AudioFileGetProperty failed, get audio data format"))
            return -1;
        
        NSTimeInterval sec;
        nSize = sizeof(sec);
        if (noErr == AudioFileGetProperty(mAudioFile, kAudioFilePropertyEstimatedDuration, &nSize, &sec)) {
            mDuration = [[NSNumber alloc] initWithDouble:sec];
        }
        NSLog(@"File duration:%f",[self getFileDuration]);
        
        mAudioData.maxNumFrames = sec * mAudioDataFormat.mSampleRate;
        mAudioData.frameNum = 0;
        mAudioData.player = (__bridge void *)(self);
        
        UInt64 nPackets;
        nSize = sizeof(nPackets);
        if (noErr != checkError(AudioFileGetProperty(mAudioFile, kAudioFilePropertyAudioDataPacketCount, &nSize, &nPackets), "AudioFileGetProperty failed, get file packets count"))
            return -1;
        
        if (nil == [self createDLBAUGraph])
            return -1;
        
        //Set AudioFileId for FilePlayer Unit
        if (noErr != checkError(AudioUnitSetProperty(mPlayerAU, kAudioUnitProperty_ScheduledFileIDs, kAudioUnitScope_Global, 0, &mAudioFile, sizeof(mAudioFile)), "AudioUnitSetProperty failed, set AudioFileId"))
            return -1;
     
        //Set the FilePlayer Unit region to whole file
        ScheduledAudioFileRegion afrgn;
        memset(&afrgn.mTimeStamp, 0, sizeof(afrgn.mTimeStamp));
        afrgn.mTimeStamp.mFlags = kAudioTimeStampSampleTimeValid;
        afrgn.mTimeStamp.mSampleTime = 0;
        afrgn.mCompletionProc = NULL;
        afrgn.mCompletionProcUserData = NULL;
        afrgn.mAudioFile = mAudioFile;
        afrgn.mLoopCount = 0;
        afrgn.mStartFrame = 0;
        afrgn.mFramesToPlay = (UInt32)nPackets * mAudioDataFormat.mFramesPerPacket;
    
        if (noErr != checkError(AudioUnitSetProperty(mPlayerAU, kAudioUnitProperty_ScheduledFileRegion, kAudioUnitScope_Global, 0, &afrgn, sizeof(afrgn)), "AudioUnitSetProperty failed, set file region"))
            return -1;
    
        
        //Prime
        UInt32 val = 0;
        if (noErr != checkError(AudioUnitSetProperty(mPlayerAU, kAudioUnitProperty_ScheduledFilePrime, kAudioUnitScope_Global, 0, &val, sizeof(val)), "AudioUnitSetProperty failed, prime the player"))
            return -1;
        
        
        AudioTimeStamp startTS;
        memset(&startTS,0,sizeof(startTS));
        startTS.mFlags = kAudioTimeStampSampleTimeValid;
        startTS.mSampleTime = -1;
        if (noErr != checkError(AudioUnitSetProperty(mPlayerAU, kAudioUnitProperty_ScheduleStartTimeStamp, kAudioUnitScope_Global, 0, &startTS, sizeof(startTS)), "AudioUnitSetProperty failed, set start timestamp"))
            return -1;
        
        //Start the graph
        if (noErr != checkError(AUGraphStart(mGraph), "AUGraphStart failed"))
            return -1;
    
        mStarted = YES;
        
        return 0;
    }
    
    -(id) initWithAudio:(NSString *)path{
        
        if (!(self=[super init])) return nil;
        if (!path) {
            NSLog(@"*** Error *** DLBAUGraphPlayer init path is nil\n");
            return nil;
            
        }
        mError = 0;
        
        mStarted = NO;
        
        NSError *error = nil;
        AVAudioSession *session = [AVAudioSession sharedInstance];
        [session setPreferredOutputNumberOfChannels:8 error:&error];
        bool success = [session setActive:YES error:&error];
        NSAssert(success, @"Error setting AVAudioSession active! %@", [error localizedDescription]);
        
        NSUInteger channels = session.maximumOutputNumberOfChannels;
        NSLog(@"channels:%lu", (unsigned long)channels);
        mError = [self startPlayback:path];
        
        return self;
        
    }
    
    -(int8_t)getPlayingStatus{
        
        if (mError < 0) {
            return mError;
        }
        
        return mStarted;
    }
    
    -(Float32)getCurrentPlaybackPos{
        
        if (!mStarted)
            return 0.0;
        
        Float32 pos = mAudioData.frameNum / 44100.0;
        
        if (pos > mDuration.doubleValue) {
            return mDuration.doubleValue;
        }
        
        return pos;
        
    }
    
    -(Float32)getFileDuration{
        
        return mDuration.doubleValue;
    }
    
    -(void)stopPlayback{
        
        if (!mStarted)
            return;
        
        mStarted = NO;
        mError = 0;
        AUGraphStop(mGraph);
        AUGraphUninitialize(mGraph);
        AUGraphClose(mGraph);
        AudioFileClose(mAudioFile);
        
    }
    
    -(void)dealloc{
        NSLog(@"DLBAUGraphPlayer dealloced!");
        if (mStarted ) {
            [self stopPlayback];
        }
    
    }
    
    @end
    															    
    																    #import "DLBAVAudioEngine.h"
    
    
    
    @implementation DLBAVAudioEngine
    
    
    + (AVAudioEngine*)sharedEngine
    {
        static dispatch_once_t once;
        static AVAudioEngine* result = nil;
        dispatch_once(&once, ^{
            result = [[AVAudioEngine alloc] init];
        });
        return result;
    }
    
    
    -(id) initWithAudio:(NSString *)path{
        
        if (!path) {
            NSLog(@"*** Error *** DLBAVAudioEngine init path is nil\n");
            return nil;
            
        }
        mError = 0;
        
        NSError *error = nil;
        AVAudioSession *sessionInstance = [AVAudioSession sharedInstance];
        
        // set the session category
        bool success = [sessionInstance setCategory:AVAudioSessionCategoryMultiRoute withOptions:AVAudioSessionCategoryOptionMixWithOthers error:&error];
        NSAssert(success, @"Error setting AVAudioSession category! %@", [error localizedDescription]);
        
        // activate the audio session
        success = [sessionInstance setActive:YES error:&error];
        NSAssert(success, @"Error setting AVAudioSession active! %@", [error localizedDescription]);
        
        // AVAudioEngine setup
        AVAudioEngine * audioengine = [self.class sharedEngine];
        AVAudioOutputNode *output = audioengine.outputNode;
        AVAudioMixerNode *mixer = audioengine.mainMixerNode;
        
        audioplayer = [[AVAudioPlayerNode alloc] init];
        [audioengine attachNode:audioplayer];
        
        // open the file to play
        NSURL* url = [NSURL fileURLWithPath:path];
        avFile = [[AVAudioFile alloc] initForReading:url error: &error];
        
        // make connections
        AVAudioFormat *outformat = [output outputFormatForBus:0];
        [audioengine connect:audioplayer to:mixer format:[avFile processingFormat]];
        [audioengine connect:mixer to:output format:outformat];
        
        // schedule the file on player
        @try {
            [audioplayer scheduleFile:avFile atTime:nil completionHandler:^{
                mEnd = YES;
            }];
        } @catch (NSException *exception) {
            NSLog(@"*** Error *** DLBAVAudioEngine catch exception: %@%@\n", [exception name], [exception reason]);
            mError = -1;
            return nil;
            
        } @finally {
        }
        
        // start engine and player
        success = [audioengine startAndReturnError:&error];
        NSAssert(success, @"Error starting engine! %@", [error localizedDescription]);
        
        [audioplayer play];
        mStarted = YES;
        mEnd = NO;
        
        return self;
        
    }
    
    -(int8_t)getPlayingStatus{
        
        if (mError < 0) {
            return mError;
        }
        
        return mStarted;
    }
    
    -(void)stopPlayback{
        
        if (!mStarted)
            return;
        
        mStarted = NO;
        mEnd = YES;
        mError = 0;
        
        [audioplayer stop];
        audioplayer = nil;
    }
    
    -(Float32)getCurrentPlaybackPos{
        
        if (mEnd) {
            return [self getFileDuration];
        }
        
        if (!mStarted) {
            return 0.0;
        }
        
        if (audioplayer.lastRenderTime > 0) {
            
            NSTimeInterval currentTime = ((NSTimeInterval)[audioplayer playerTimeForNodeTime:audioplayer.lastRenderTime].sampleTime / avFile.fileFormat.sampleRate);
            
            if (currentTime > 0) {
                return currentTime;
            }
        }
        
        return 0.0;
        
    }
    
    -(Float32)getFileDuration{
        
        double sr = avFile.fileFormat.sampleRate;
        if ( sr <= 0)
            return 0.0;
        
        return avFile.length/sr;
    }
    
    @end
    															    

    Specs

    Platform Dolby Digital(ac3) Dolby Digital Plus (ec3)
    iPhone 7 Series
    iPhone 6 Series
    iPhone SE
    iPhone 5s and newer
    iPhone 5c and older
    iPad Pro Series
    iPad Air Series
    iPad mini 2/3/4
    Original iPad Series
    iPod touch 6th Gen

    Sample Project

    iOS Sample Code

    iOS_Sample_Code N/A mb
    View on Github

    tvOS

    With the 4th Generation Apple TV, Apple has added support for Dolby Audio and made the Dolby Digital Plus format accessible to tvOS Developers. As a tvOS App Developer you can now include the Dolby Digital Plus format into your tvOS Applications. Want to deliver a consistent playback experience to your customers? Encode your content in Dolby Digital Plus and include it into your application today!

    Click here to learn more about Dolby Audio

    Code Snippet

    																    // Sample code using the AVPlayer Class
    //
    //
    #import "DLBAVPlayer.h"
    
    @implementation DLBAVPlayer
    
    -(id) initWithPath:(NSString *)path{
        
        if (!(self=[super init])) return nil;
        if (!path) {
            NSLog(@"*** Error *** DLBAVPlayer init path is nil\n");
            return nil;
        }
    /*
        //NSURL *movieURL = [[NSBundle mainBundle] URLForResource:@"2ch_dd_audio" withExtension:@"mp4"];
        NSURL *movieURL = [NSURL fileURLWithPath:path];
        AVAsset *movieAsset = [AVURLAsset URLAssetWithURL:movieURL options:nil];
        AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:movieAsset];
        AVPlayer *player = [AVPlayer playerWithPlayerItem:playerItem];
        AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player];
        playerLayer.frame = self.view.layer.bounds;
        
        [self.view.layer addSublayer:playerLayer];
        [player play];
    */    
        return self;   
    }
    @end
    															    
    																    #import "DLBAVAudioPlayer.h"
    
    AVAudioPlayer *audioplayer;
    
    @implementation DLBAVAudioPlayer
    
    -(id) initWithAudio:(NSString *)path{
        
        if (!path) {
            NSLog(@"*** Error *** DLBAVAudioPlayer init path is nil\n");
            return nil; 
        }
        mError = 0;
    
        audioplayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:nil];
        //audioplayer.delegate = self;
        //[audioplayer setNumberOfLoops:0];
        [audioplayer play];
        
        mStarted = YES;
        mEnd = NO;
        
        return self;
    }
    
    -(void)audioPlayerDidFinishPlaying:(AVAudioPlayer*)player successfully:(BOOL)flag {
        mEnd = YES;
    }
    
    -(int8_t)getPlayingStatus{
        
        if (mError < 0) {
            return mError;
        }
        return mStarted;
    }
    
    -(Float32)getCurrentPlaybackPos{
        
        if (!mStarted)
            return 0.0;
        
        if (mEnd) {
            return [self getFileDuration];
        }
        return audioplayer.currentTime;
    }
    
    -(Float32)getFileDuration{
        
        return audioplayer.duration;
    }
    
    -(void) stopPlayback{
        
        mStarted = NO;
        mEnd = YES;
        
        [audioplayer stop];
    }
    @end
    															    
    																    #import "DLBAUGraphPlayer.h"
    
    @implementation DLBAUGraphPlayer
    
    
    OSStatus checkError(OSStatus err, const char * msg)
    {
        if (noErr == err)
            return noErr;
        
        char errStr[30]={0};
        
        *(UInt32 *)(errStr + 1) = CFSwapInt32HostToBig(err);
        
        if (isprint(errStr[1]) && isprint(errStr[2]) && isprint(errStr[3]) && isprint(errStr[4]))
        {
            errStr[0]=errStr[5]='\'';
            errStr[6]='\0';
        }
        else {
            sprintf(errStr,"%d",(int)err);
        }
        
        NSLog(@"*** Error *** %s, (%s) \n",msg,errStr);
        
        return err;
    }
    
    static OSStatus renderNotification(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData)
    {
        
        if (*ioActionFlags == kAudioUnitRenderAction_PostRender) {
            
            AudioBufferDataPtr data = (AudioBufferDataPtr)inRefCon;
            //DLBAUGraphPlayer *player = (__bridge DLBAUGraphPlayer *)data->player;
            
            data->frameNum += inNumberFrames;
        }
        
        return noErr;
    }
    
    -(id)createDLBAUGraph
    {
        //Create AUGraph
        if (noErr != checkError(NewAUGraph(&mGraph), "NewAUGraph failed") )
            return nil;
        
        //Create description for output
        AudioComponentDescription outputDesc = {0};
        outputDesc.componentType = kAudioUnitType_Output;
        outputDesc.componentSubType = kAudioUnitSubType_RemoteIO;
        outputDesc.componentManufacturer = kAudioUnitManufacturer_Apple;
        
        //Create description for file player
        AudioComponentDescription playerDesc = {0};
        playerDesc.componentType = kAudioUnitType_Generator;
        playerDesc.componentSubType = kAudioUnitSubType_AudioFilePlayer;
        playerDesc.componentManufacturer = kAudioUnitManufacturer_Apple;
        
        //Add output node
        if (noErr != checkError(AUGraphAddNode(mGraph, &outputDesc, &mOutputNode), "AUGraphAddNode failed, adding output node"))
            return nil;
        
        //Add player node
        
        if (noErr != checkError(AUGraphAddNode(mGraph, &playerDesc, &mPlayerNode), "AUGraphAddNode failde, add player node"))
            return nil;
        
        //Open the graph
        if (noErr != checkError(AUGraphOpen(mGraph), "AUGraphOpen failde"))
            return nil;
        
        //Get the AudioUnit object
        if (noErr != checkError(AUGraphNodeInfo(mGraph, mPlayerNode, NULL, &mPlayerAU), "AUGraphNodeInfo failed"))
            return nil;
        
        //Connect player node to output
        if (noErr != checkError(AUGraphConnectNodeInput(mGraph, mPlayerNode, 0, mOutputNode, 0),"AUGraphConnectNodeInput failed"))
            return nil;
        
        //Add render notification after the render operation is complete
        AUGraphAddRenderNotify(mGraph, renderNotification, &mAudioData);
        
        //Init the graph
        if (noErr != checkError(AUGraphInitialize(mGraph),"AUGraphInitialize failed"))
            return nil;
        
        return self;
    }
    
    -(int8_t)startPlayback:(NSString *)path{
        
        //Open the audio file
        if (noErr != checkError(AudioFileOpenURL((__bridge CFURLRef)[NSURL fileURLWithPath:path], kAudioFileReadPermission, 0, &mAudioFile),"AudioFileOpenURL failed"))
            return -1;
        
        UInt32 nSize = sizeof(mAudioDataFormat);
        if (noErr != checkError(AudioFileGetProperty(mAudioFile, kAudioFilePropertyDataFormat, &nSize, &mAudioDataFormat), "AudioFileGetProperty failed, get audio data format"))
            return -1;
        
        NSTimeInterval sec;
        nSize = sizeof(sec);
        if (noErr == AudioFileGetProperty(mAudioFile, kAudioFilePropertyEstimatedDuration, &nSize, &sec)) {
            mDuration = [[NSNumber alloc] initWithDouble:sec];
        }
        NSLog(@"File duration:%f",[self getFileDuration]);
        
        mAudioData.maxNumFrames = sec * mAudioDataFormat.mSampleRate;
        mAudioData.frameNum = 0;
        mAudioData.player = (__bridge void *)(self);
        
        UInt64 nPackets;
        nSize = sizeof(nPackets);
        if (noErr != checkError(AudioFileGetProperty(mAudioFile, kAudioFilePropertyAudioDataPacketCount, &nSize, &nPackets), "AudioFileGetProperty failed, get file packets count"))
            return -1;
        
        if (nil == [self createDLBAUGraph])
            return -1;
        
        //Set AudioFileId for FilePlayer Unit
        if (noErr != checkError(AudioUnitSetProperty(mPlayerAU, kAudioUnitProperty_ScheduledFileIDs, kAudioUnitScope_Global, 0, &mAudioFile, sizeof(mAudioFile)), "AudioUnitSetProperty failed, set AudioFileId"))
            return -1;
     
        //Set the FilePlayer Unit region to whole file
        ScheduledAudioFileRegion afrgn;
        memset(&afrgn.mTimeStamp, 0, sizeof(afrgn.mTimeStamp));
        afrgn.mTimeStamp.mFlags = kAudioTimeStampSampleTimeValid;
        afrgn.mTimeStamp.mSampleTime = 0;
        afrgn.mCompletionProc = NULL;
        afrgn.mCompletionProcUserData = NULL;
        afrgn.mAudioFile = mAudioFile;
        afrgn.mLoopCount = 0;
        afrgn.mStartFrame = 0;
        afrgn.mFramesToPlay = (UInt32)nPackets * mAudioDataFormat.mFramesPerPacket;
    
        if (noErr != checkError(AudioUnitSetProperty(mPlayerAU, kAudioUnitProperty_ScheduledFileRegion, kAudioUnitScope_Global, 0, &afrgn, sizeof(afrgn)), "AudioUnitSetProperty failed, set file region"))
            return -1;
    
        //Prime
        UInt32 val = 0;
        if (noErr != checkError(AudioUnitSetProperty(mPlayerAU, kAudioUnitProperty_ScheduledFilePrime, kAudioUnitScope_Global, 0, &val, sizeof(val)), "AudioUnitSetProperty failed, prime the player"))
            return -1;
        
        
        AudioTimeStamp startTS;
        memset(&startTS,0,sizeof(startTS));
        startTS.mFlags = kAudioTimeStampSampleTimeValid;
        startTS.mSampleTime = -1;
        if (noErr != checkError(AudioUnitSetProperty(mPlayerAU, kAudioUnitProperty_ScheduleStartTimeStamp, kAudioUnitScope_Global, 0, &startTS, sizeof(startTS)), "AudioUnitSetProperty failed, set start timestamp"))
            return -1;
        
        //Start the graph
        if (noErr != checkError(AUGraphStart(mGraph), "AUGraphStart failed"))
            return -1;
    
         mStarted = YES;
        
        return 0;
    }
    
    -(id) initWithAudio:(NSString *)path{
        
        if (!(self=[super init])) return nil;
        if (!path) {
            NSLog(@"*** Error *** DLBAUGraphPlayer init path is nil\n");
            return nil;
            
        }
        mError = 0;
        mStarted = NO;
        mError = [self startPlayback:path];
        
        return self;
    }
    
    -(int8_t)getPlayingStatus{
        
        if (mError < 0) {
            return mError;
        }
        return mStarted;
    }
    
    -(Float32)getCurrentPlaybackPos{
        
        if (!mStarted)
            return 0.0;
        
        Float32 pos = mAudioData.frameNum / 44100.0;
        
        if (pos > mDuration.doubleValue) {
            return mDuration.doubleValue;
        }
        return pos;
    }
    
    -(Float32)getFileDuration{
        
        return mDuration.doubleValue;
    }
    
    -(void)stopPlayback{
        
        if (!mStarted)
            return;
        
        mStarted = NO;
        mError = 0;
        AUGraphStop(mGraph);
        AUGraphUninitialize(mGraph);
        AUGraphClose(mGraph);
        AudioFileClose(mAudioFile);
    }
    
    -(void)dealloc{
        NSLog(@"DLBAUGraphPlayer dealloced!");
        if (mStarted ) {
            [self stopPlayback];
        }
    }
    @end
    															    
    																    #import "DLBAVAudioEngine.h"
    
    @implementation DLBAVAudioEngine
    
    + (AVAudioEngine*)sharedEngine
    {
        static dispatch_once_t once;
        static AVAudioEngine* result = nil;
        dispatch_once(&once, ^{
            result = [[AVAudioEngine alloc] init];
        });
        return result;
    }
    
    -(id) initWithAudio:(NSString *)path{
        
        if (!path) {
            NSLog(@"*** Error *** DLBAVAudioEngine init path is nil\n");
            return nil;
            
        }
        mError = 0;
        
        NSError *error = nil;
        AVAudioSession *sessionInstance = [AVAudioSession sharedInstance];
        
        // set the session category
        bool success = [sessionInstance setCategory:AVAudioSessionCategoryMultiRoute withOptions:AVAudioSessionCategoryOptionMixWithOthers error:&error];
        NSAssert(success, @"Error setting AVAudioSession category! %@", [error localizedDescription]);
        
        // activate the audio session
        success = [sessionInstance setActive:YES error:&error];
        NSAssert(success, @"Error setting AVAudioSession active! %@", [error localizedDescription]);
        
        // AVAudioEngine setup
        AVAudioEngine * audioengine = [self.class sharedEngine];
        AVAudioOutputNode *output = audioengine.outputNode;
        AVAudioMixerNode *mixer = audioengine.mainMixerNode;
        
        audioplayer = [[AVAudioPlayerNode alloc] init];
        [audioengine attachNode:audioplayer];
        
        // open the file to play
        NSURL* url = [NSURL fileURLWithPath:path];
        avFile = [[AVAudioFile alloc] initForReading:url error: &error];
        
        // make connections
        AVAudioFormat *outformat = [output outputFormatForBus:0];
        [audioengine connect:audioplayer to:mixer format:[avFile processingFormat]];
        [audioengine connect:mixer to:output format:outformat];
        
        // schedule the file on player
        @try {
            [audioplayer scheduleFile:avFile atTime:nil completionHandler:^{
                mEnd = YES;
            }];
        } @catch (NSException *exception) {
            NSLog(@"*** Error *** DLBAVAudioEngine catch exception: %@%@\n", [exception name], [exception reason]);
            mError = -1;
            return nil;
            
        } @finally {
        }
        
        // start engine and player
        success = [audioengine startAndReturnError:&error];
        NSAssert(success, @"Error starting engine! %@", [error localizedDescription]);
        
        [audioplayer play];
        mStarted = YES;
        mEnd = NO;
        
        return self;
    }
    
    -(int8_t)getPlayingStatus{
        
        if (mError < 0) {
            return mError;
        }
        
        return mStarted;
    }
    
    -(void)stopPlayback{
        
        if (!mStarted)
            return;
        
        mStarted = NO;
        mEnd = YES;
        mError = 0;
        
        [audioplayer stop];
        audioplayer = nil;
    }
    
    -(Float32)getCurrentPlaybackPos{
        
        if (mEnd) {
            return [self getFileDuration];
        }
        
        if (!mStarted) {
            return 0.0;
        }
        
        if (audioplayer.lastRenderTime > 0) {
            
            NSTimeInterval currentTime = ((NSTimeInterval)[audioplayer playerTimeForNodeTime:audioplayer.lastRenderTime].sampleTime / avFile.fileFormat.sampleRate);
            
            if (currentTime > 0) {
                return currentTime;
            }
        }
        return 0.0;
    }
    
    -(Float32)getFileDuration{
        
        double sr = avFile.fileFormat.sampleRate;
        if ( sr <= 0)
            return 0.0;
        
        return avFile.length/sr;
    }
    @end
    															    

    Specs

    Platform Dolby Digital(ac3) Dolby Digital Plus (ec3)
    Apple TV - 4th Gen
    Apple TV - 3rd Gen *
    Apple TV - 2nd Gen *
    * Dolby Digital Passthrough Only

    Sample Project

    tvOS Sample Code

    iOS_Sample_Code N/A mb
    View on Github

    macOS Sierra

    In macOS Sierra, Apple continues to support Dolby Audio and has made the Dolby Digital Plus format accessible to Apple Developers on the macOS platform. Using the Dolby Digital Plus format will ensure a consistent playback experience on all devices. This is a great way to differentiate and enhance the audio experience for your customers. So, what are you waiting for? Encode your content in Dolby Digital Plus and include it into your application today!

    Click here to learn more about Dolby Audio

    Code Snippet

    																    //
    // Coming Soon. While we're putting something together for you, visit 
    // https://developer.apple.com/library/mac/samplecode/AVSimplePlayerOSX/Introduction/Intro.html
    															    

    Specs

    Platform Dolby Digital(ac3) Dolby Digital Plus (ec3)
    macOS Sierra
    OS X El Capitan
    OS X Yosemite *
    OS X Mavericks *
    * Dolby Digital Passthrough Only

    Sample Project

    AVSimplePlayer Sample Project from Apple's Developer Site

    Intro.html 0.24 mb
    Visit Apple Developer

    ROKU Ultra

    The Roku Ultra now includes Dolby Digital Plus. Some of the benefits include the following:

    - Loudness Management
    - 5.1 multi-channel support
    - HDMI ARC support
    - Improved experience with voice commands
    - Native support for System Sound Mixing in Dolby Audio
     
    Want to deliver the best audio experience to your Roku customer? Deliver your assets Dolby Digital Plus

    Code Snippet

    																    // Here is some sample BrightScript code demonstrating how to determine if the attached device supports Dolby Digital Plus audio
    // Dolby Digital Plus can be checked by using roDeviceInfo.CanDecodeAudio();
    
    Function CanDecodeDolbyDigitalPlusAudio() as Boolean
         dev_info = createObject("roDeviceInfo")
         return dev_info.CanDecodeAudio({"Codec":"eac3"}).result
    End Function
    															    

    Specs

    Platform Dolby Digital(ac3) Dolby Digital Plus (ec3)
    Roku Ultra (2016)
    Roku 4 (2015) *
    Roku Premier+ and below *
    * Dolby Digital Passthrough Only

    Sample Project

    Roku Sample Project

    dolby-audio-sample.git .25 mb
    View on GitHub

    Dolby Atmos for VR

    At Dolby, we believe that virtual reality holds the promise to transform every segment of the home entertainment market. We're committed to help make this happen through providing VR content creators and distributors with the tools and technologies needed to enable amazing VR experiences.

    Download VR content creation tools (requires login)

    The Dolby Atmos Production Suite can be purchased through the Avid Store.

    Click here to visit our Knowledge base & Forums.