Skip to content

Commit

Permalink
Audio engine
Browse files Browse the repository at this point in the history
Adds an audio engine abstraction (implemented with miniaudio) in Rive. We can selectively replace it with other abstractions later if we find miniaudio isn't well suited everywhere but I'm confident it will be based on flexibility with getting it working in the recorder.

Adds audio support in:

- packages/rive_common
  - WASM: rive_audio_wasm.dart
  - FFI: rive_audio_ffi.dart
- packages/runtime
- packages/recorder

Subsequent PR will add support in:

- packages/rive_unity
  - This is getting meaty enough...
- packages/rive_flutter
  - This requires publishing rive_common so I want to make sure this is reviewed and accepted before publishing
  - I'd also prefer to merge layout constraints into rive_common before this lands.

Editor features:
- Updated preview window:
<img width="248" alt="CleanShot 2024-01-15 at 14 44 31@2x" src="https://github.com/rive-app/rive/assets/454182/a9588be6-8370-4e22-ab32-af1e9ed71183">

- Preview waveforms in the timeline:
<img width="651" alt="CleanShot 2024-01-15 at 14 44 53@2x" src="https://github.com/rive-app/rive/assets/454182/2710667f-838f-483d-9647-e2bcb9e0237a">

- Subsequent PR will also use threads in web editor build (currently uses a time/frame based decoder to offload ui). I can't do that until I can verify the Shared Memory access is granted once rive_common lands in pub.dev and then we can push to UAT.

Diffs=
73bf11db3 Audio engine (#6454)

Co-authored-by: Luigi Rosso <luigi-rosso@users.noreply.github.com>
  • Loading branch information
luigi-rosso and luigi-rosso committed Jan 23, 2024
1 parent 453e996 commit 8168e18
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b098ad23a15cc7b11f144e407374c83d5db0fee0
73bf11db39230e7a6d302da9a27414d35bcbee99
28 changes: 28 additions & 0 deletions RiveRuntime.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@
04ED72F3299C115100E8DE53 /* empty_animation_state.riv in Resources */ = {isa = PBXBuildFile; fileRef = 04ED72F2299C115100E8DE53 /* empty_animation_state.riv */; };
2A7079352726277C00C035A1 /* rive_renderer_view.hh in Headers */ = {isa = PBXBuildFile; fileRef = 2A7079342726277C00C035A1 /* rive_renderer_view.hh */; settings = {ATTRIBUTES = (Public, ); }; };
2A707937272628AD00C035A1 /* rive_renderer_view.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2A707936272628AD00C035A1 /* rive_renderer_view.mm */; };
2AD589B02B5705D800CD1D24 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2AD589AF2B5705D800CD1D24 /* AVFoundation.framework */; };
2AD589B22B573C9F00CD1D24 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2AD589B12B573C9F00CD1D24 /* CoreAudio.framework */; };
2AD589B32B574BF700CD1D24 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2AD589AF2B5705D800CD1D24 /* AVFoundation.framework */; };
2AD589B62B574C0A00CD1D24 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2AD589B12B573C9F00CD1D24 /* CoreAudio.framework */; };
2AD589BA2B57589400CD1D24 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2AD589B92B57589400CD1D24 /* AudioToolbox.framework */; };
2AD589BB2B57589B00CD1D24 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2AD589B92B57589400CD1D24 /* AudioToolbox.framework */; };
83DE4C912AA8DD7B00B88B72 /* RenderContextManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83DE4C902AA8DD7B00B88B72 /* RenderContextManager.mm */; };
83DE4C932AA8DD9F00B88B72 /* RenderContextManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 83DE4C922AA8DD9F00B88B72 /* RenderContextManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
83DE4CA02AAA072B00B88B72 /* PlatformCGImage.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83DE4C9F2AAA072B00B88B72 /* PlatformCGImage.mm */; };
Expand Down Expand Up @@ -151,6 +157,10 @@
04ED72F2299C115100E8DE53 /* empty_animation_state.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = empty_animation_state.riv; sourceTree = "<group>"; };
2A7079342726277C00C035A1 /* rive_renderer_view.hh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rive_renderer_view.hh; sourceTree = "<group>"; };
2A707936272628AD00C035A1 /* rive_renderer_view.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = rive_renderer_view.mm; sourceTree = "<group>"; };
2AD589AF2B5705D800CD1D24 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
2AD589B12B573C9F00CD1D24 /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = System/Library/Frameworks/CoreAudio.framework; sourceTree = SDKROOT; };
2AD589B42B574C0000CD1D24 /* AudioUnit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioUnit.framework; path = System/Library/Frameworks/AudioUnit.framework; sourceTree = SDKROOT; };
2AD589B92B57589400CD1D24 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
83DE4C902AA8DD7B00B88B72 /* RenderContextManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = RenderContextManager.mm; path = Source/Renderer/RenderContextManager.mm; sourceTree = SOURCE_ROOT; };
83DE4C922AA8DD9F00B88B72 /* RenderContextManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderContextManager.h; sourceTree = "<group>"; };
83DE4C9F2AAA072B00B88B72 /* PlatformCGImage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlatformCGImage.mm; sourceTree = "<group>"; };
Expand Down Expand Up @@ -187,13 +197,19 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
2AD589BB2B57589B00CD1D24 /* AudioToolbox.framework in Frameworks */,
2AD589B62B574C0A00CD1D24 /* CoreAudio.framework in Frameworks */,
2AD589B32B574BF700CD1D24 /* AVFoundation.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
C9C73ED724FC478900EF9516 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
2AD589BA2B57589400CD1D24 /* AudioToolbox.framework in Frameworks */,
2AD589B22B573C9F00CD1D24 /* CoreAudio.framework in Frameworks */,
2AD589B02B5705D800CD1D24 /* AVFoundation.framework in Frameworks */,
C9161A81263CBCBC007749A1 /* RiveRuntime.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -254,6 +270,17 @@
path = Assets;
sourceTree = "<group>";
};
2AD589AE2B5705D800CD1D24 /* Frameworks */ = {
isa = PBXGroup;
children = (
2AD589B92B57589400CD1D24 /* AudioToolbox.framework */,
2AD589B42B574C0000CD1D24 /* AudioUnit.framework */,
2AD589B12B573C9F00CD1D24 /* CoreAudio.framework */,
2AD589AF2B5705D800CD1D24 /* AVFoundation.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
C3468E5627EB9858008652FD /* Utils */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -297,6 +324,7 @@
C9C73ED324FC478800EF9516 /* Source */,
C9C73EDE24FC478900EF9516 /* Tests */,
C9C73ED224FC478800EF9516 /* Products */,
2AD589AE2B5705D800CD1D24 /* Frameworks */,
);
sourceTree = "<group>";
};
Expand Down
2 changes: 1 addition & 1 deletion submodules/rive-cpp

0 comments on commit 8168e18

Please sign in to comment.