Skip to content

Commit

Permalink
v2.0.0-pre.3
Browse files Browse the repository at this point in the history
  • Loading branch information
alnitak committed Mar 20, 2024
1 parent feb3d48 commit de5e181
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 48 deletions.
69 changes: 34 additions & 35 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,10 @@
#### 2.0.0-pre.X
#### 2.0.0-pre.3 (20 Mar 2024)
- added `getActiveVoiceCount()` to get concurrent sounds that are playing at the moment.
- added `countAudioSource()` to get concurrent sounds that are playing a specific audio source.
- added `getVoiceCount()` to get the number of voices the application has told SoLoud to play.
- added `getMaxActiveVoiceCount()` to get the current maximum active voice count.
- added `setMaxActiveVoiceCount()` to set the current maximum active voice count.
- added `setProtectVoice()` and `getProtectVoice()` to get/set the protect voice flag.

#### 2.0.0-pre.2 (14 Mar 2024)

NOTE: This version is much more breaking than the ones before it.
It might be worth it to first upgrade your code to `2.0.0-pre.1`,
use the quick fixes to rename the methods, and only then upgrade
to `2.0.0-pre.2` and beyond.

- `SoLoud` methods now throw instead of returning a `PlayerErrors` object.
This is a massive breaking change, but it makes the package API
more idiomatic and easier to use.

Before:

```dart
final ret = await SoLoud.play(sound);
if (ret.error != PlayerErrors.noError) {
print('Oh no! ${ret.error}');
} else {
print('Playing sound with new handle: ${ret.newHandle}');
}
```

After:

```dart
try {
final handle = await SoLoud.play(sound);
print('Playing sound with new handle: $handle');
} on SoLoudException catch (e) {
print('Oh no! $e');
}
```
- All time-related parameters and return values are now `Duration` type.
Before, they were `double`.
- Fixed velocity computation bug in `example/`.
Expand Down Expand Up @@ -68,13 +35,45 @@ to `2.0.0-pre.2` and beyond.
);
soloud.play(source);
```

- Deprecated `shutdown()`. Replaced with the synchronous `deinit()`.
Quick fix available.
- Renamed `initialize()` to `init()`, in order to come closer to the original
C++ API, and also to have a symmetry (`init`/`deinit`).
Quick fix available.

#### 2.0.0-pre.2 (14 Mar 2024)

NOTE: This version is much more breaking than the ones before it.
It might be worth it to first upgrade your code to `2.0.0-pre.1`,
use the quick fixes to rename the methods, and only then upgrade
to `2.0.0-pre.2` and beyond.

- `SoLoud` methods now throw instead of returning a `PlayerErrors` object.
This is a massive breaking change, but it makes the package API
more idiomatic and easier to use.

Before:

```dart
final ret = await SoLoud.play(sound);
if (ret.error != PlayerErrors.noError) {
print('Oh no! ${ret.error}');
} else {
print('Playing sound with new handle: ${ret.newHandle}');
}
```

After:

```dart
try {
final handle = await SoLoud.play(sound);
print('Playing sound with new handle: $handle');
} on SoLoudException catch (e) {
print('Oh no! $e');
}
```

#### 2.0.0-pre.1 (12 Mar 2024)
- added `looping` and `loopingStartAt` properties to `SoLoud.play()` and `SoLoud.play3d()`.
- added `SoLoud.getLooping()` to retrieve the looping state of a sound.
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.0.0-pre.2"
version: "2.0.0-pre.3"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down
12 changes: 5 additions & 7 deletions lib/src/bindings_player_ffi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ class FlutterSoLoudFfi {
return _isInited() == 1;
}

late final _isInitedPtr =
_lookup<ffi.NativeFunction<ffi.Int Function()>>(
late final _isInitedPtr = _lookup<ffi.NativeFunction<ffi.Int Function()>>(
'isInited',
);
late final _isInited = _isInitedPtr.asFunction<int Function()>();
Expand Down Expand Up @@ -837,9 +836,9 @@ class FlutterSoLoudFfi {
/// NOTE: The number of concurrent voices is limited, as having unlimited
/// voices would cause performance issues, as well as lead to unnecessary
/// clipping. The default number of concurrent voices is 16, but this can be
/// adjusted at runtime. The hard maximum number is 4095, but if more are
/// adjusted at runtime. The hard maximum number is 4095, but if more are
/// required, SoLoud can be modified to support more. But seriously, if you
/// need more than 4095 sounds at once, you're probably going to make
/// need more than 4095 sounds at once, you're probably going to make
/// some serious changes in any case.
void setMaxActiveVoiceCount(int maxVoiceCount) {
return _setMaxActiveVoiceCount(maxVoiceCount);
Expand All @@ -851,7 +850,6 @@ class FlutterSoLoudFfi {
late final _setMaxActiveVoiceCount =
_setMaxActiveVoiceCountPtr.asFunction<void Function(int)>();


/////////////////////////////////////////
/// faders
/////////////////////////////////////////
Expand Down Expand Up @@ -1062,9 +1060,9 @@ class FlutterSoLoudFfi {
/// Returns:
/// [PlayerErrors.noError] if no errors
/// [PlayerErrors.filterNotFound] if the [filterType] does not exits
/// [PlayerErrors.filterAlreadyAdded] when trying to add an already
/// [PlayerErrors.filterAlreadyAdded] when trying to add an already
/// added filter
/// [PlayerErrors.maxNumberOfFiltersReached] when the maximum number of
/// [PlayerErrors.maxNumberOfFiltersReached] when the maximum number of
/// filters has been reached (default is 8)
///
PlayerErrors addGlobalFilter(int filterType) {
Expand Down
5 changes: 3 additions & 2 deletions lib/src/exceptions/exceptions_from_cpp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,14 @@ class SoLoudMaxFilterNumberReachedException extends SoLoudCppException {
'is allowed (on the C++ side).';
}

/// An exception that is thrown when SoLoud (C++) cannot add a filter
/// An exception that is thrown when SoLoud (C++) cannot add a filter
/// that has already been added.
class SoLoudFilterAlreadyAddedException extends SoLoudCppException {
/// Creates a new [SoLoudFilterAlreadyAddedException].
const SoLoudFilterAlreadyAddedException([super.message]);

@override
String get description => 'Askind to add a filter that is already been added. '
String get description =>
'Askind to add a filter that is already been added. '
'Only one of each type is allowed (on the C++ side).';
}
5 changes: 3 additions & 2 deletions lib/src/soloud.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1792,11 +1792,12 @@ interface class SoLoud {
}

/// Add a filter to all sounds.
///
/// [filterType] filter to add.
///
/// Throws [SoLoudMaxFilterNumberReachedException] when the max number of
/// Throws [SoLoudMaxFilterNumberReachedException] when the max number of
/// concurrent filter is reached (default max filter is 8).
/// Throws [SoLoudFilterAlreadyAddedException] when trying to add a filter
/// Throws [SoLoudFilterAlreadyAddedException] when trying to add a filter
/// that has already been added.
void addGlobalFilter(FilterType filterType) {
final e = SoLoudController().soLoudFFI.addGlobalFilter(filterType.index);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: flutter_soloud
description: >-
Flutter audio plugin using SoLoud library with miniaudio backend and FFI.
It provides player, basic capture from microphone, 3D audio and more.
version: 2.0.0-pre.2
version: 2.0.0-pre.3
issue_tracker: https://github.com/alnitak/flutter_soloud/issues
homepage: https://github.com/alnitak/flutter_soloud
maintainer: Marco Bavagnoli (@lildeimos)
Expand Down

0 comments on commit de5e181

Please sign in to comment.