-
Notifications
You must be signed in to change notification settings - Fork 649
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Native CoreAudio renderer with spatial audio
* Inspired by an example app from Apple. [1] * Needs an M1 or newer Mac. * Operates in a standard passthrough mode for stereo or when you have enough real channels (HDMI). * When headphones or built-in Macbook speakers are used and a 5.1 or 7.1 stream is being sent by Sunshine, this will render the surround channels into high quality spatial audio. * Supports optional head-tracking (enable in settings). * Supports personalized HRTF if you've scanned your ears with your iPhone. This can greatly improve spatial audio for many people. Known issues: * System sound menu does not indicate spatial audio is active or that multichannel audio is playing. * If Moonlight is in Game Mode and you toggle back and forth by say, swiping out of full screen to another app, the audio may stutter a bit. [1] https://developer.apple.com/documentation/audiotoolbox/generating_spatial_audio_from_a_multichannel_audio_stream
- Loading branch information
1 parent
7e10056
commit 2660e79
Showing
19 changed files
with
2,046 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>com.apple.security.app-sandbox</key> | ||
<true/> | ||
<key>com.apple.developer.spatial-audio.profile-access</key> | ||
<true/> | ||
<key>com.apple.developer.coremotion.head-pose</key> | ||
<true/> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
app/streaming/audio/renderers/coreaudio/AllocatedAudioBufferList.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
Copyright © 2024 Apple Inc. | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
documentation files (the "Software"), to deal in the Software without restriction, including without limitation | ||
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, | ||
and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | ||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
#pragma once | ||
|
||
#include <AudioToolbox/AudioToolbox.h> | ||
|
||
class AllocatedAudioBufferList | ||
{ | ||
public: | ||
AllocatedAudioBufferList(UInt32 channelCount, uint16_t bufferSize) | ||
{ | ||
|
||
mBufferList = static_cast<AudioBufferList *>(malloc(sizeof(AudioBufferList) + (sizeof(AudioBuffer) * channelCount))); | ||
mBufferList->mNumberBuffers = channelCount; | ||
for (UInt32 c = 0; c < channelCount; ++c) { | ||
mBufferList->mBuffers[c].mNumberChannels = 1; | ||
mBufferList->mBuffers[c].mDataByteSize = bufferSize * sizeof(float); | ||
mBufferList->mBuffers[c].mData = malloc(sizeof(float) * bufferSize); | ||
} | ||
} | ||
|
||
AllocatedAudioBufferList(const AllocatedAudioBufferList&) = delete; | ||
|
||
AllocatedAudioBufferList& operator=(const AllocatedAudioBufferList&) = delete; | ||
|
||
~AllocatedAudioBufferList() | ||
{ | ||
if (mBufferList == nullptr) { return; } | ||
|
||
for (UInt32 i = 0; i < mBufferList->mNumberBuffers; ++i) { | ||
free(mBufferList->mBuffers[i].mData); | ||
} | ||
free(mBufferList); | ||
mBufferList = nullptr; | ||
} | ||
|
||
AudioBufferList * _Nonnull get() | ||
{ | ||
return mBufferList; | ||
} | ||
|
||
private: | ||
AudioBufferList * _Nonnull mBufferList = { nullptr }; | ||
}; |
Oops, something went wrong.