You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Opus and Ogg libraries are currently only used by the BufferStream to receive and fill audio data with Opus format and they are enabled by default.
2
+
3
+
These libs are prebuilt for all platforms and stored in the plugin folder. This means that even if they are not needed, the plugin still requires them to work, and the size of the app will grow slightly. To address this, a new environment variable has been introduced that can be used to prevent the prebuilt libs from being linked to the final app.
4
+
5
+
If trying to use, for example the `SoLoud.setBufferStream()` function, an exception will be thrown if the environment variable has been set.
6
+
7
+
---
8
+
9
+
### How to set the environment variable:
10
+
11
+
**Linux - Android - Windows**
12
+
13
+
If using **VS Code**, add `NO_OPUS_OGG_LIBS` set to an empty string in the `env` key to the *.vscode/launch.json* configuration, for example:
14
+
15
+
```
16
+
{
17
+
"name": "Flutter debug",
18
+
"type": "dart",
19
+
"request": "launch",
20
+
"program": "lib/buffer_stream/websocket.dart",
21
+
"flutterMode": "debug",
22
+
"env": {
23
+
"NO_OPUS_OGG_LIBS": "1"
24
+
},
25
+
"cwd": "${workspaceFolder}/example"
26
+
}
27
+
```
28
+
29
+
If using **Android Studio**, add `NO_OPUS_OGG_LIBS="1"` in the *Run/Debug Configurations* configuration under **Environment Variables** text field.
30
+
31
+
Alternatively, you can set the variable in the terminal and build the app, for example:
32
+
33
+
```
34
+
flutter clean
35
+
flutter pub get
36
+
NO_OPUS_OGG_LIBS="1" && flutter run
37
+
```
38
+
39
+
**MacOS - iOS**
40
+
41
+
To set the environment variable on MacOS and iOS, you can add the following line to the `app/ios/Podfile` or `app/macos/Podfile` at the top of the file:
42
+
43
+
```
44
+
ENV['NO_OPUS_OGG_LIBS'] = '1'
45
+
```
46
+
47
+
Alternatively, you can set the variable in the terminal and build the app, for example:
48
+
49
+
```
50
+
flutter clean
51
+
flutter pub get
52
+
NO_OPUS_OGG_LIBS="1" && flutter run
53
+
```
54
+
if the environment variable was already been used before for testing purposes, you can use the following command:
55
+
```
56
+
flutter clean
57
+
flutter pub get
58
+
NO_OPUS_OGG_LIBS= && flutter run <-- this will unset the environment variable
59
+
```
60
+
61
+
> [!NOTE]
62
+
> The environment variable set in VS Code or in Android Studio will be ignored.
63
+
64
+
**Web**
65
+
66
+
To set the environment variable on Web, open `web/compile_wasm.sh` and change the line `NO_OPUS_OGG_LIBS="0"` to `NO_OPUS_OGG_LIBS="1"`.
67
+
You should then run the script to build the WASM and JS files. You must have `emscripten` installed.
68
+
69
+
The script works on Linux and probably on MacOS. Windows users should run the script in WSL or wait until a *.bat* script is available.
70
+
71
+
> [!NOTE]
72
+
> The environment variable set in VS Code or in Android Studio will be ignored.
Copy file name to clipboardExpand all lines: README.md
+1-7Lines changed: 1 addition & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,13 +47,7 @@ In other words, it is calling the C/C++ methods of the underlying audio engine d
47
47
#### Opus format for streaming
48
48
When using an `AudioSource` as an audio stream to play custom audio data (ie using setBufferStream/addAudioDataStream/setDataIsEnded), it is possible to add PCM RAW audio data in *s8*, *s16le*, *s32le*, *f32le* and since it supports also the *opus* format with the Ogg codec (ie to work with OpenAI APIs), the [Opus](https://www.opus-codec.org/) and [Ogg](https://xiph.org/ogg/) libraries from [Xiph.org](https://www.xiph.org/) are needed.
49
49
50
-
On Linux and MacOS theese libraries must be installed if you want to use this kind of `AudioSource`:
51
-
-**Linux**
52
-
- install them depending on the package manager used by you distribution
53
-
-**MacOS**
54
-
-`brew install opus libogg`
55
-
56
-
if the libraries are not found the plugin will throw an exception when calling `setBufferStream` using Opus format.
50
+
These libraries are embedded and enabled by default for all platforms. This leads to an increased binary size by 600~1500 kb depending on platform. If you don't need to use audio streaming, hence you don't need the Opus and Ogg libraries, you can read the [NO_OPUS_OGG_LIBS.md](https://github.com/alnitak/flutter_soloud/blob/main/NO_OPUS_OGG_LIBS.md) for details.
57
51
58
52
The `SoLoud.setBufferStream` supports also `BufferingType.preserved` which behaves the same as a normal `AudioSource`, and `BufferingType.released` which will free the memory of the already played audio for longer playback. The latter will accept to play only one instance of the audio stream at the same time.
0 commit comments