Skip to content

Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.

C

feat: Vibrations previews each tap on rings that ripple

My-Name-Is-Jeff32e5e25e2e10
diff --git a/docs/tweaks.md b/docs/tweaks.md
index 694a1d50..9ee3bf76 100644
--- a/docs/tweaks.md
+++ b/docs/tweaks.md
@@ -441,8 +441,8 @@ the mic on and off at once, its Status (a tap says more), the Vocals slider (gon
(where the iPhone reads headphone motion; a page of its own, reading out On or Off, with a live preview at its top that
follows the head through AirPods, or sways gently without them and holds still under Reduce Motion, a line under it
saying which, then the switch), the voice model's download, Runs on (GPU, GPU
-and Neural Engine, Neural Engine) and Ignore heat warnings, all applying straight away. Player: Gestures, AirPods gestures, Blocked
-artists (with the count on the row) and Lock screen widget (Moving artwork, Lyrics or Every song, and the
+and Neural Engine, Neural Engine) and Ignore heat warnings, all applying straight away. Player: Gestures, AirPods gestures, Vibrations (which
+of the two are on read out on the row), Blocked artists (with the count on the row) and Lock screen widget (Moving artwork, Lyrics or Every song, and the
lyrics' style, Still or Animated, and Spotify's like and dislike buttons' flag; its podcast, audiobook and artwork
flags stay in All flags), which work with either look;
in the native look also Now playing bar (its device button and its flags), Queue & devices, and
@@ -452,12 +452,18 @@ buttons to hide); in the redesign the page instead leads with a showcase of the
PlayerSettings.m): a small copy of it over the background chosen, the cover, title and artist, and a glass sheet over
the artwork with its progress and volume sliders and the transport between them; under it the Background pull-down
(Still, Colours, Fluid, Animated, changing the showcase at once), Download in Low Data Mode while Animated is
-chosen, and the now playing bar's device button, checked in the simulator against harness/player/ (`settings`). Then Vibrations under either look, a card for
+chosen, and the now playing bar's device button, checked in the simulator against harness/player/ (`settings`). Vibrations, a page of its own under either
+look, leads with a preview (Shared/Haptics/SGVibrationsPreview.m): rings of dots that a tap sends a crest across, out
+from the middle in the accent colour, higher and further the stronger the Strength, while the first of Controls and
+Generated that is on plays its own tap through its own path (Controls' add tap, or one kick of Generated's with its
+rumble unless it follows Beat), the line under it naming which, or saying why there is none. While the page shows,
+each tap Generated plays sends a low crest too. Nothing runs between crests, and with Reduce Motion the rings light
+up together and fade instead of moving. Under it a card for
Controls (on until switched off) and one for Music Haptics, a choice of None, Generated or Native iOS
(left out below iOS 18) with an ⓘ saying what each does. Someone with no choice stored gets Native iOS
when Music Haptics is on in Accessibility, else Generated if the old switch was on, else None. Controls
has its Strength under it, greyed out while the switch is off (10 to 100%, a tap at the new strength with each step);
-Generated into its Strength (20 to 200%, 100% being how it first shipped) and Follows, Everything (a tap on
+Generated into its Strength (20 to 200%, 100% being how it first shipped, a kick at the new strength with each step) and Follows, Everything (a tap on
each kick and snare and a rumble under the bass), Beat (the taps without the rumble) or Bass (the kicks'
taps and the rumble); Native iOS into a Status row (Off in iOS, Paused, Waiting, Checking, Ready, Playing
or Unavailable), all applying straight away. Live Activity, on iOS 17 and up under either look: its switch and which view it
diff --git a/harness/haptics-page/README.md b/harness/haptics-page/README.md
index f968e6dd..8814b6b1 100644
--- a/harness/haptics-page/README.md
+++ b/harness/haptics-page/README.md
@@ -1,9 +1,10 @@
# Vibrations settings harness
-Mod Settings > Player's Vibrations cards (`tweak/Sources/Shared/Haptics/HapticsSettings.m`) on an SGModPage laid
-out like the Player page in the redesign: the real Settings/ framework (its slider row and its rows shown while a
+Mod Settings > Player > Vibrations (`tweak/Sources/Shared/Haptics/HapticsSettings.m`), its preview
+(`SGVibrationsPreview.m`) and its cards: the real Settings/ framework (its slider row and its rows shown while a
switch is on), the real control taps (`SGFeedback.m`, which the simulator plays silently), and `stubs.m` for Music
-Haptics' engine, which logs each call with the strength and the Follows choice the hook would read.
+Haptics' engine, which logs each call with the strength and the Follows choice the hook would read, and keeps
+the preview's watcher for `pulse` to hand a tap of the music's to.
THEOS=$HOME/theos ./build.sh
xcrun simctl install <udid> build/HapticsPageHarness.app
@@ -16,8 +17,13 @@ setup words (`controls-off`, `music`, `follows=<n>`, `slow`) and the actions, pl
flipping a switch, dragging a slider and letting go, VoiceOver's swipe on one, the ⓘ, a tap on a row (the Follows
row, then a name in its list), and `dump`, which logs the stored keys, what the hooks read and the rows shown:
- xcrun simctl launch --console-pty <udid> com.vojta.hapticspageharness controls-off bottom toggle=2.0 slide=2.1:40 \
- toggle=3.0 slide=3.1:150 swipe=3.1:-3 dump select=3.2 select=0.1 dump
+ xcrun simctl launch --console-pty <udid> com.vojta.hapticspageharness controls-off bottom toggle=0.0 slide=0.1:40 \
+ toggle=1.0 slide=1.1:150 swipe=1.1:-3 dump select=1.2 select=0.1 dump
+
+`tap` taps the preview (as VoiceOver's double tap does) and `pulse=<intensity>` hands it a tap of Music Haptics';
+with `slow` a screenshot every second or so catches the crest on its way out:
+
+ xcrun simctl launch <udid> com.vojta.hapticspageharness slow tap
2026-09-19, iPhone 17 Pro (402pt) and iPhone 13 mini (375pt) on iOS 26.5: both switches off, Controls on with its
Strength, Music Haptics on in each Follows choice, the Follows list with a line under each choice, and the rows
@@ -30,3 +36,15 @@ it), `select=2.1` on it leans the Controls switch 6pt towards on and springs it
Strength back to full strength without a row moving.
What it does not cover: a real finger on the slider, and how any strength feels, which only a phone can tell.
+
+2026-10-06, iPhone 17 Pro on iOS 27.0: the page opens on the preview, its line reading Tap to feel Controls, Tap to
+feel Music Haptics (`controls-off music`), the Native iOS note (`controls-off native`) or what to turn on
+(`controls-off`), and Tap to feel Controls again once `toggle=0.0` turns Controls on; with `slow tap`, six shots
+1.3 s apart show the middle dipping and one lit ring travelling out to the edge and the field settling back to
+rest; with Reduce Motion on (`simctl spawn <udid> defaults write com.apple.Accessibility ReduceMotionEnabled -bool
+true`) every ring lights at once and fades, nothing moving. With Generated, `tap` asks the engine for its preview kick
+at the stored strength with the rumble, and each step of `slide=1.1:150` asks again at the new strength. The line
+wraps under accessibility-medium text and the cards move down under it.
+
+Not covered here: how the taps feel, whether the preview kick reaches a running engine on a phone, and the
+music's pulses with real music playing (`pulse` stands in for them).
diff --git a/harness/haptics-page/build.sh b/harness/haptics-page/build.sh
index 3f6ee0d4..b1f9e8b1 100755
--- a/harness/haptics-page/build.sh
+++ b/harness/haptics-page/build.sh
@@ -10,7 +10,7 @@ SDK=$(xcrun --sdk iphonesimulator --show-sdk-path)
xcrun -sdk iphonesimulator clang -target arm64-apple-ios17.0-simulator -fobjc-arc -g -O0 \
-I"$SRC" -isysroot "$SDK" -Wall -Werror -Wno-deprecated-declarations \
"$(dirname "$0")/main.m" "$(dirname "$0")/stubs.m" "$(dirname "$0")/../scene.m" \
- "$SRC"/Shared/Haptics/HapticsSettings.m "$SRC"/Shared/Haptics/SGFeedback.m \
+ "$SRC"/Shared/Haptics/HapticsSettings.m "$SRC"/Shared/Haptics/SGVibrationsPreview.m "$SRC"/Shared/Haptics/SGFeedback.m \
"$SRC"/Settings/SGPage.m "$SRC"/Settings/SGPageStyle.m "$SRC"/Settings/SGModPage.m "$SRC"/Settings/SGGlowSwitch.m \
"$SRC"/Core/SGLog.m "$SRC"/Core/SGPrefs.m "$SRC"/Core/SGViewTree.m "$SRC"/Core/SGFlagForce.m "$SRC"/Core/SGUIMode.m \
-framework UIKit -framework QuartzCore -framework CoreGraphics -framework Foundation \
diff --git a/harness/haptics-page/main.m b/harness/haptics-page/main.m
index aeb7c126..7fc81e1d 100644
--- a/harness/haptics-page/main.m
+++ b/harness/haptics-page/main.m
@@ -1,6 +1,5 @@
-// Mod Settings > Player's Vibrations cards (Shared/Haptics/HapticsSettings.m) on an SGModPage laid out like the
-// Player page in the redesign, with the real Settings/ framework and SGFeedback.m behind them and stubs.m for
-// Music Haptics' engine. The launch line sets the switches up and then plays actions, one every 0.7 s from 1 s
+// Mod Settings > Player > Vibrations (Shared/Haptics/HapticsSettings.m), its preview (SGVibrationsPreview.m) and
+// its cards, with the real Settings/ framework and SGFeedback.m behind them and stubs.m for Music Haptics' engine. The launch line sets the switches up and then plays actions, one every 0.7 s from 1 s
// in; screenshot after.
//
// THEOS=$HOME/theos ./build.sh && xcrun simctl install <udid> build/HapticsPageHarness.app
@@ -10,7 +9,8 @@
// controls-off (Controls switched off), music (Music Haptics on Generated), native (on Native iOS), follows=<n>, slow (animations at a twentieth
// of their speed).
// Actions: toggle=<section>.<row> (that row's switch flipped the way a tap does), slide=<section>.<row>:<value>
-// (that slider dragged there and let go), swipe=<section>.<row>:<n> (VoiceOver's swipe up on it, n times, down
+// (that slider dragged there and let go), tap (the preview tapped, as VoiceOver's double tap does it),
+// pulse=<intensity> (a tap of Music Haptics' handed to the preview, as the engine does while the page shows), swipe=<section>.<row>:<n> (VoiceOver's swipe up on it, n times, down
// for a negative n), info=<section>.<row> (a tap on its ⓘ), select=<section>.<row> (a tap on a row of the page
// on top), pop, bottom (scrolled to the end), dump (the stored haptics keys, what the hooks would read, and the
// rows each section shows, to the log).
@@ -19,6 +19,8 @@
#import "Settings/SGModPage.h"
#import "Shared/Haptics/Haptics.h"
+void SGHarnessPulse(float intensity); // stubs.m
+
static void findViews(UIView *root, Class kind, NSMutableArray *found) {
if ([root isKindOfClass:kind]) [found addObject:root];
for (UIView *sub in root.subviews) findViews(sub, kind, found);
@@ -31,22 +33,6 @@ static void findViews(UIView *root, Class kind, NSMutableArray *found) {
@implementation AppDelegate
-// The Player page as App/Pages.m builds it in the redesign, its links standing in for the pages they open.
-- (UIViewController *)playerPage {
- UIViewController *(^none)(void) = ^UIViewController *{ return nil; };
- SGModRow *blocked = SGPageRow(@"Blocked artists", none);
- blocked.value = ^NSString *{ return @"Off"; };
- NSMutableArray<SGModSection *> *sections = [NSMutableArray arrayWithArray:@[
- SGSection(nil, @[SGWithTile(SGPageRow(@"Gestures", none), @"hand.tap", UIColor.systemBlueColor), SGWithTile(SGPageRow(@"Lyrics", none), @"quote.bubble", UIColor.systemPurpleColor),
- SGWithTile(blocked, @"person.crop.circle.badge.xmark", UIColor.systemRedColor)]),
- SGSection(nil, @[SGWithTile(SGPageRow(@"Now playing", none), @"rectangle.bottomthird.inset.filled", UIColor.systemPinkColor),
- SGWithTile(SGPageRow(@"Lock screen widget", none), @"lock", UIColor.systemGrayColor)]),
- ]];
- [sections addObjectsFromArray:SGVibrationsSections()];
- return [[SGModPage alloc] initWithTitle:@"Player" intro:@"Changes apply after you restart Spotify. Gestures, Blocked artists and Vibrations apply straight away."
- sections:sections footer:nil];
-}
-
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)options {
NSArray<NSString *> *args = NSProcessInfo.processInfo.arguments;
NSUserDefaults *store = NSUserDefaults.standardUserDefaults;
@@ -66,7 +52,7 @@ static void findViews(UIView *root, Class kind, NSMutableArray *found) {
self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
self.window.overrideUserInterfaceStyle = UIUserInterfaceStyleDark;
- self.nav = [[UINavigationController alloc] initWithRootViewController:[self playerPage]];
+ self.nav = [[UINavigationController alloc] initWithRootViewController:SGVibrationsSettingsPage()];
self.window.rootViewController = self.nav;
[self.window makeKeyAndVisible];
if ([args containsObject:@"slow"]) self.window.layer.speed = 0.05;
@@ -131,6 +117,10 @@ static void findViews(UIView *root, Class kind, NSMutableArray *found) {
NSLog(@"[harness] the ⓘ shows \"%@\": %@", alert.title, [alert.message substringToIndex:MIN(60, alert.message.length)]);
} else if ([verb isEqualToString:@"select"]) {
[table.delegate tableView:table didSelectRowAtIndexPath:[self pathFrom:value]];
+ } else if ([verb isEqualToString:@"tap"]) {
+ [table.tableHeaderView accessibilityActivate];
+ } else if ([verb isEqualToString:@"pulse"]) {
+ SGHarnessPulse(value.floatValue);
} else if ([verb isEqualToString:@"pop"]) {
[self.nav popViewControllerAnimated:YES];
} else if ([verb isEqualToString:@"bottom"]) {
diff --git a/harness/haptics-page/stubs.m b/harness/haptics-page/stubs.m
index b7da4d00..674c6a81 100644
--- a/harness/haptics-page/stubs.m
+++ b/harness/haptics-page/stubs.m
@@ -1,5 +1,6 @@
// Music Haptics' side of Haptics.h (MusicHaptics.x in the tweak), which the page calls as its choice and its
-// settings change: each is logged with what the hooks would read at that moment.
+// settings change and its preview is tapped: each is logged with what the hooks would read at that moment.
+// The preview's watcher is kept, for the harness's pulse to hand a tap to.
#import "Core/SGCore.h"
#import "Shared/Haptics/Haptics.h"
@@ -12,3 +13,20 @@ __attribute__((constructor)) static void sg_logModeChanges(void) {
void SGMusicHapticsSettingsChanged(void) {
NSLog(@"[harness] Music Haptics reads strength %.0f%%, follows %ld", SGHapticsStrength(SGKeyMusicStrength) * 100, (long)SGMusicHapticsFollows());
}
+
+void SGMusicHapticsPreview(void) {
+ NSLog(@"[harness] Music Haptics plays the preview's kick at %.0f%%%@", SGHapticsStrength(SGKeyMusicStrength) * 100,
+ SGMusicHapticsFollows() == SGMusicFollowsBeat ? @"" : @" with the rumble");
+}
+
+static void (^sg_watcher)(float intensity);
+
+void SGMusicHapticsWatchTaps(void (^watcher)(float intensity)) {
+ NSLog(@"[harness] the preview %@ Music Haptics' taps", watcher ? @"watches" : @"stops watching");
+ sg_watcher = [watcher copy];
+}
+
+void SGHarnessPulse(float intensity) {
+ if (sg_watcher) sg_watcher(intensity);
+ else NSLog(@"[harness] nothing watches Music Haptics' taps");
+}
diff --git a/harness/haptics/build-sim.sh b/harness/haptics/build-sim.sh
index 6a965ce7..5f377c39 100755
--- a/harness/haptics/build-sim.sh
+++ b/harness/haptics/build-sim.sh
@@ -12,7 +12,7 @@ SRC=../../tweak/Sources
OUT=build/sim
HAPTICS="$SRC/Shared/Haptics"
EXTRA=""
-SETTINGS="$SRC/Shared/Haptics/HapticsSettings.m $SRC/Shared/Haptics/SGFeedback.m $SRC/Settings/SGPage.m $SRC/Settings/SGPageStyle.m $SRC/Settings/SGModPage.m $SRC/Settings/SGGlowSwitch.m"
+SETTINGS="$SRC/Shared/Haptics/HapticsSettings.m $SRC/Shared/Haptics/SGVibrationsPreview.m $SRC/Shared/Haptics/SGFeedback.m $SRC/Settings/SGPage.m $SRC/Settings/SGPageStyle.m $SRC/Settings/SGModPage.m $SRC/Settings/SGGlowSwitch.m"
if [ "$1" = before ]; then
HAPTICS=$2
OUT=build/sim-before
diff --git a/tweak/Sources/App/Pages.m b/tweak/Sources/App/Pages.m
index 41ad0456..6eddcb0e 100644
--- a/tweak/Sources/App/Pages.m
+++ b/tweak/Sources/App/Pages.m
@@ -135,11 +135,15 @@ UIViewController *SGPlayerSettingsPage(void) {
blocked.value = ^NSString *{
return SGFlag(SGKeyArtistBlock, NO) ? @(SGBlockedArtists().count).stringValue : @"Off";
};
+ // Vibrations hook Spotify's own controls and its audio, so they answer under either look.
+ SGModRow *vibrations = SGPageRow(@"Vibrations", ^UIViewController *{ return SGVibrationsSettingsPage(); });
+ vibrations.value = ^NSString *{ return SGVibrationsSummary(); };
BOOL native = !SGRedesignedUIStored();
NSMutableArray<SGModSection *> *sections = [NSMutableArray arrayWithObject:SGSection(nil, @[
SGWithTile(SGPageRow(@"Gestures", ^UIViewController *{ return SGGesturesSettingsPage(); }), @"hand.tap", UIColor.systemBlueColor),
SGWithTile(SGPageRow(@"AirPods gestures", ^UIViewController *{ return SGHeadGesturesSettingsPage(); }), @"airpods.pro", UIColor.systemGrayColor),
+ SGWithTile(vibrations, @"iphone.radiowaves.left.and.right", UIColor.systemOrangeColor),
SGWithTile(blocked, @"person.crop.circle.badge.xmark", UIColor.systemRedColor),
])];
NSMutableArray<SGModRow *> *pages = [NSMutableArray array];
@@ -154,8 +158,6 @@ UIViewController *SGPlayerSettingsPage(void) {
[sections addObject:SGSection(native ? nil : @"Hide on the player", @[
SGHideRow(@"Switch to video", @"The chip over the title of a song with a music video", SGKeyHideVideoSwitch),
])];
- // Vibrations hook Spotify's own controls and its audio, so they answer under either look.
- [sections addObjectsFromArray:SGVibrationsSections()];
// The redesign's page leads with a showcase of its player, the background and device button rows under it.
if (!native) return SGRPlayerSettingsPage(sections);
diff --git a/tweak/Sources/Shared/Haptics/Haptics.h b/tweak/Sources/Shared/Haptics/Haptics.h
index 23f72f84..62b0cf38 100644
--- a/tweak/Sources/Shared/Haptics/Haptics.h
+++ b/tweak/Sources/Shared/Haptics/Haptics.h
@@ -7,7 +7,8 @@
// SGMusicAnalyzer.m the listening: taps and a rumble out of the samples
// SystemMusicHaptics.x iOS's own Music Haptics given the song's Apple Music id or ISRC (Native iOS)
// SGHapticTrack.m the pure steps behind it: Spotify's extended metadata asked and read, Apple's songs matched
-// HapticsSettings.m the Vibrations cards, with each one's strength, what Music Haptics plays and follows
+// HapticsSettings.m the Vibrations page: its cards, with each one's strength, what Music Haptics plays and follows
+// SGVibrationsPreview.m the rings at the top of the page, which ripple and play the first feature on when tapped
//
// Everything on them applies at once, without a restart. Everything hooked is Spotify's own (its controls
// by accessibility identifier, its scrubber, its cover and title lists, its audio unit), so all of it works
@@ -78,6 +79,12 @@ SGMusicHapticsMode SGMusicHapticsModeNow(void);
extern NSNotificationName const SGMusicHapticsModeChangedNotification;
// From its strength and its choice of what to follow: reads them again, for the next tap.
void SGMusicHapticsSettingsChanged(void);
+// One kick of Generated's at its strength, with the rumble under it unless it follows the beat alone, played
+// at once: the Vibrations preview's tap. Nothing while Generated is not listening.
+void SGMusicHapticsPreview(void);
+// Each tap Generated plays from now on is handed to `watcher` on the main thread as it is felt, with its
+// intensity before the strength, 0 to 1; nil stops it. Main thread.
+void SGMusicHapticsWatchTaps(void (^watcher)(float intensity));
// What iOS's own Music Haptics is doing, for the settings to read out: SystemMusicHaptics.x sets it. Main thread.
NSString *SGMusicHapticsStatus(void);
void SGSetMusicHapticsStatus(NSString *status);
@@ -86,7 +93,8 @@ void SGSetMusicHapticsStatus(NSString *status);
double SGHapticsStrength(NSString *key);
SGMusicFollows SGMusicHapticsFollows(void);
-@class SGModSection;
-// The Vibrations sections of the Player page: a card for Controls and one for Music Haptics, each opening
-// out into its settings while its switch is on.
-NSArray<SGModSection *> *SGVibrationsSections(void);
+// The Vibrations page, linked from the Player page: the preview, then a card for Controls and one for Music
+// Haptics, each opening out into its settings while it is on.
+UIViewController *SGVibrationsSettingsPage(void);
+// What the Player page's Vibrations row reads out: which of the two are on.
+NSString *SGVibrationsSummary(void);
diff --git a/tweak/Sources/Shared/Haptics/HapticsSettings.m b/tweak/Sources/Shared/Haptics/HapticsSettings.m
index f998cb39..db02f25d 100644
--- a/tweak/Sources/Shared/Haptics/HapticsSettings.m
+++ b/tweak/Sources/Shared/Haptics/HapticsSettings.m
@@ -1,12 +1,14 @@
-// The Vibrations sections of the Player page, under either look (App/Pages.m puts them there): a card
-// per kind, the way the Audio effects page has one per effect. Controls is a switch that opens out into its
-// strength. Music Haptics is a choice of which plays, None, Generated or Native iOS, since the two never play
-// at once: Generated opens out into its strength and what it follows (a choice that also says whether the
-// rumble plays, rather than a switch of its own that one choice would leave with nothing to do), Native
-// into what iOS's own is doing.
+// The Vibrations page, under either look (App/Pages.m links it from the Player page): the preview at the
+// top (SGVibrationsPreview.m), then a card per kind, the way the Audio effects page has one per effect.
+// Controls is a switch that opens out into its strength. Music Haptics is a choice of which plays, None,
+// Generated or Native iOS, since the two never play at once: Generated opens out into its strength and what
+// it follows (a choice that also says whether the rumble plays, rather than a switch of its own that one
+// choice would leave with nothing to do), Native into what iOS's own is doing. Each strength's slider plays
+// a tap at the new strength with each step, and the preview ripples with it.
#import "Core/SGCore.h"
#import "Settings/SGModPage.h"
#import "Haptics.h"
+#import "SGVibrationsPreview.h"
static NSString *const kMusicHapticsInfo = @"Generated: the iPhone taps along with the drums and rumbles under the bass of whatever Spotify is playing, worked out from the sound as it plays. It follows the sound this iPhone plays while Spotify is open: iOS plays no haptics for an app in the background, and a song playing on another device through Connect has no sound here to follow.\n\nNative iOS: iOS plays Apple Music's own haptic track for the song, in the background and on the lock screen too, for songs Apple Music has one for. It needs iOS 18 and Music Haptics on in Settings > Accessibility, and stays quiet for podcasts and songs Apple has none for.\n\nNone: no Music Haptics. Controls is separate.";
@@ -86,11 +88,15 @@ static SGModRow *strengthRow(NSString *key, void (^changed)(void)) {
^NSString *(double value) { return [NSString stringWithFormat:@"%ld%%", lround(value)]; });
}
-NSArray<SGModSection *> *SGVibrationsSections(void) {
+// The cards, `preview` told when something it reads out changes and shown the slider's taps.
+static NSArray<SGModSection *> *sections(SGVibrationsPreview *preview) {
+ __weak SGVibrationsPreview *weakPreview = preview;
SGModRow *controls = SGSwitchRow(@"Controls", nil, SGKeyControlHaptics);
+ controls.changed = ^(BOOL on) { [weakPreview reload]; };
SGModRow *controlStrength = strengthRow(SGKeyControlStrength, ^{
- // Felt as it is set: a tap at the new strength with each step.
+ // Felt as it is set, and seen: a tap at the new strength with each step, and its ripple.
SGPlayFeedback(SGFeedbackAdd);
+ [weakPreview rippleAt:SGHapticsStrength(SGKeyControlStrength)];
});
controlStrength.waitsOn = SGKeyControlHaptics;
@@ -101,9 +107,15 @@ NSArray<SGModSection *> *SGVibrationsSections(void) {
music.choiceNotes = modeNotes();
music.chosen = ^(NSInteger index) {
[NSNotificationCenter.defaultCenter postNotificationName:SGMusicHapticsModeChangedNotification object:nil];
+ [weakPreview reload];
};
BOOL (^generated)(void) = ^BOOL { return SGMusicHapticsModeNow() == SGMusicHapticsGenerated; };
- SGModRow *musicStrength = strengthRow(SGKeyMusicStrength, ^{ SGMusicHapticsSettingsChanged(); });
+ SGModRow *musicStrength = strengthRow(SGKeyMusicStrength, ^{
+ // As Controls' Strength: a kick at the new strength with each step, and its ripple.
+ SGMusicHapticsSettingsChanged();
+ SGMusicHapticsPreview();
+ [weakPreview rippleAt:SGHapticsStrength(SGKeyMusicStrength) / 2];
+ });
musicStrength.visible = generated;
SGModRow *follows = SGChoiceRow(@"Follows", nil, SGKeyMusicFollows, followsNames(), SGMusicFollowsEverything);
follows.choiceNotes = followsNotes();
@@ -113,7 +125,63 @@ NSArray<SGModSection *> *SGVibrationsSections(void) {
status.visible = ^BOOL { return SGMusicHapticsModeNow() == SGMusicHapticsNative; };
return @[
- SGSection(@"Vibrations", @[SGWithSymbol(controls, @"hand.tap"), controlStrength]),
+ SGSection(nil, @[SGWithSymbol(controls, @"hand.tap"), controlStrength]),
SGSection(nil, @[SGWithSymbol(music, @"waveform"), musicStrength, follows, status]),
];
}
+
+#pragma mark - the page
+
+@interface SGVibrationsPage : SGModPage
+@property (nonatomic, strong) SGVibrationsPreview *preview;
+@end
+
+@implementation SGVibrationsPage
+
+- (void)viewDidLoad {
+ [super viewDidLoad];
+ self.tableView.tableHeaderView = self.preview;
+}
+
+// The header keeps the height it is given, so it is sized here and handed back to the table only when that
+// changes (a table header set on every pass lays the table out again forever).
+- (void)viewWillLayoutSubviews {
+ [super viewWillLayoutSubviews];
+ UITableView *table = self.tableView;
+ CGFloat width = table.bounds.size.width;
+ self.preview.layoutMargins = UIEdgeInsetsMake(0, table.layoutMargins.left, 0, table.layoutMargins.right);
+ CGSize size = CGSizeMake(width, [self.preview heightForWidth:width]);
+ if (CGSizeEqualToSize(self.preview.bounds.size, size)) return;
+ self.preview.frame = (CGRect){CGPointZero, size};
+ table.tableHeaderView = self.preview;
+}
+
+- (void)viewWillAppear:(BOOL)animated {
+ [super viewWillAppear:animated];
+ [self.preview reload];
+}
+
+- (void)viewDidAppear:(BOOL)animated {
+ [super viewDidAppear:animated];
+ self.preview.listening = YES;
+}
+
+- (void)viewWillDisappear:(BOOL)animated {
+ [super viewWillDisappear:animated];
+ self.preview.listening = NO;
+}
+
+@end
+
+UIViewController *SGVibrationsSettingsPage(void) {
+ SGVibrationsPreview *preview = [SGVibrationsPreview new];
+ SGVibrationsPage *page = [[SGVibrationsPage alloc] initWithTitle:@"Vibrations" intro:nil sections:sections(preview) footer:nil];
+ page.preview = preview;
+ return page;
+}
+
+NSString *SGVibrationsSummary(void) {
+ BOOL controls = SGEnabled(SGKeyControlHaptics), music = SGMusicHapticsModeNow() != SGMusicHapticsOff;
+ if (controls && music) return @"On";
+ return controls ? @"Controls" : music ? @"Music Haptics" : @"Off";
+}
diff --git a/tweak/Sources/Shared/Haptics/MusicHaptics.x b/tweak/Sources/Shared/Haptics/MusicHaptics.x
index f2e47b9a..26d514b7 100644
--- a/tweak/Sources/Shared/Haptics/MusicHaptics.x
+++ b/tweak/Sources/Shared/Haptics/MusicHaptics.x
@@ -16,6 +16,8 @@
// continuous event whose intensity follows the level. The strength scales both as they are played, and
// what Music Haptics follows leaves out the snares' taps (Bass) or the rumble (Beat) there too, so a change
// applies to the next event.
+// The Vibrations page's preview asks for one kick, which the same thread plays at once through the same
+// engine and strength, and while the page shows, each tap played is handed back to it for its rings.
//
// The rebinding and the notify are in place under either look, so the choice works at once; with
// anything but Generated chosen the notify returns straight away. Nothing listens while Spotify is not the
@@ -73,6 +75,8 @@ static atomic_uint_fast64_t sg_skipped; // renders whose buffers were not laid
// The strength's factor and what is followed, set on the main thread, read on the player thread.
static atomic_uint_fast64_t sg_strengthBits;
static atomic_int sg_follows;
+// A tap the Vibrations preview asked for, and whether it is watching the taps (SGMusicHapticsWatchTaps).
+static atomic_bool sg_previewAsked, sg_watched;
static SGMusicEvent sg_ring[kRingSize];
static atomic_uint sg_head, sg_tail; // head moved by the render thread, tail by the player thread
@@ -334,6 +338,14 @@ static CHHapticEventParameter *parameter(CHHapticEventParameterID identifier, fl
return [[CHHapticEventParameter alloc] initWithParameterID:identifier value:value];
}
+static void (^sg_watcher)(float intensity); // main thread
+
+static void tellWatcher(float intensity, double lead) {
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(MAX(0, lead) * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+ if (sg_watcher) sg_watcher(intensity);
+ });
+}
+
static void playTap(const SGMusicEvent *event) {
double lead;
NSTimeInterval at = engineTime(event->hostTime, &lead);
@@ -355,10 +367,30 @@ static void playTap(const SGMusicEvent *event) {
return;
}
sg_stats.taps++;
+ if (atomic_load_explicit(&sg_watched, memory_order_relaxed)) tellWatcher(event->intensity, lead);
sg_stats.leadSum += lead;
sg_stats.leadMin = sg_stats.taps == 1 ? lead : MIN(sg_stats.leadMin, lead);
}
+// The preview's kick: a tap at the strength a full kick plays at, and under it a moment of the rumble unless
+// only the beat is followed, both now rather than when a sound is heard.
+static void playPreview(BOOL rumbles) {
+ NSMutableArray<CHHapticEvent *> *events = [NSMutableArray arrayWithObject:[[CHHapticEvent alloc] initWithEventType:CHHapticEventTypeHapticTransient parameters:@[
+ parameter(CHHapticEventParameterIDHapticIntensity, MIN(1, kTapGain * strength())),
+ parameter(CHHapticEventParameterIDHapticSharpness, 0.4f),
+ ] relativeTime:0]];
+ if (rumbles) {
+ [events addObject:[[CHHapticEvent alloc] initWithEventType:CHHapticEventTypeHapticContinuous parameters:@[
+ parameter(CHHapticEventParameterIDHapticIntensity, MIN(1, 0.5f * kRumbleGain * strength())),
+ parameter(CHHapticEventParameterIDHapticSharpness, 0),
+ ] relativeTime:0.02 duration:0.22]];
+ }
+ NSError *error = nil;
+ CHHapticPattern *pattern = [[CHHapticPattern alloc] initWithEvents:events parameters:@[] error:&error];
+ id<CHHapticPatternPlayer> player = pattern ? [sg_engine createPlayerWithPattern:pattern error:&error] : nil;
+ if (!player || ![player startAtTime:CHHapticTimeImmediate error:&error]) SGLog(@"music haptics: the preview did not play: %@", error);
+}
+
static void stopRumble(NSTimeInterval at) {
if (!sg_rumbling) return;
[sg_rumble stopAtTime:at error:nil];
@@ -450,6 +482,7 @@ static void *playerLoop(void *unused) {
@autoreleasepool {
double now = hostSeconds(mach_absolute_time());
if (!atomic_load(&sg_listening)) {
+ atomic_store(&sg_previewAsked, false);
atomic_store(&sg_tail, atomic_load(&sg_head));
stopEngine();
idle = YES;
@@ -459,6 +492,10 @@ static void *playerLoop(void *unused) {
BOOL rumbles = follows != SGMusicFollowsBeat, snares = follows != SGMusicFollowsBass;
if (!rumbles) stopRumble(CHHapticTimeImmediate);
BOOL any = NO;
+ if (atomic_exchange(&sg_previewAsked, false) && startEngine()) {
+ playPreview(rumbles);
+ any = YES;
+ }
unsigned head = atomic_load(&sg_head), tail = atomic_load(&sg_tail);
if (tail != head && startEngine()) {
for (; tail != head; tail++) {
@@ -528,6 +565,17 @@ void SGMusicHapticsSettingsChanged(void) {
dispatch_semaphore_signal(sg_wake);
}
+void SGMusicHapticsPreview(void) {
+ if (!sg_wake || !atomic_load(&sg_listening)) return;
+ atomic_store(&sg_previewAsked, true);
+ dispatch_semaphore_signal(sg_wake);
+}
+
+void SGMusicHapticsWatchTaps(void (^watcher)(float intensity)) {
+ sg_watcher = [watcher copy];
+ atomic_store(&sg_watched, watcher != nil);
+}
+
%ctor {
SGMigrateKey(SGKeyMusicHapticsWas, SGKeyMusicHaptics);
SGMigrateKey(SGKeyMusicStrengthWas, SGKeyMusicStrength);
diff --git a/tweak/Sources/Shared/Haptics/SGVibrationsPreview.h b/tweak/Sources/Shared/Haptics/SGVibrationsPreview.h
new file mode 100644
index 00000000..782491a4
--- /dev/null
+++ b/tweak/Sources/Shared/Haptics/SGVibrationsPreview.h
@@ -0,0 +1,15 @@
+// The top of the Vibrations page: rings of dots that ripple out from the middle when tapped, while the
+// Taptic Engine plays the tap of the page's first feature that is on, and a line under them naming it.
+// Threading: main thread only.
+#import <UIKit/UIKit.h>
+
+@interface SGVibrationsPreview : UIView
+// Music Haptics' taps pulse the rings gently while this is on; the page turns it on only while it shows.
+@property (nonatomic) BOOL listening;
+// Reads again which feature a tap plays, for the line under the rings.
+- (void)reload;
+// The height the preview needs at `width`, its line at the current text size.
+- (CGFloat)heightForWidth:(CGFloat)width;
+// A ripple with no tap of its own, at a strength of 0 to 1: for a tap played elsewhere on the page.
+- (void)rippleAt:(CGFloat)strength;
+@end
diff --git a/tweak/Sources/Shared/Haptics/SGVibrationsPreview.m b/tweak/Sources/Shared/Haptics/SGVibrationsPreview.m
new file mode 100644
index 00000000..bbdfaf08
--- /dev/null
+++ b/tweak/Sources/Shared/Haptics/SGVibrationsPreview.m
@@ -0,0 +1,260 @@
+// Rings of dots seen from above, like a drop on still water: a tap presses the middle and a crest runs out
+// ring by ring, pushing each ring's dots out a few points and lighting them in the look's accent colour as it
+// passes, the Taptic Engine playing on the same frame. The stronger the feature's Strength, the higher the
+// crest and the further it carries; at the lowest it dies out a few rings in. Music Haptics' taps, while it
+// is on and the page shows, send out a low crest of their own that fades within the inner rings.
+//
+// Each ring is a CAReplicatorLayer copying one white dot and one accent dot around it, so a ring is
+// animated by animating its two dots. The animations are additive keyframes that start and end at nothing,
+// so a crest sent while another runs passes through it instead of cutting it off, and nothing runs between
+// taps: no display link, no animation left over. With Reduce Motion nothing moves: every ring lights up at
+// once and fades, and the music's taps send nothing.
+#import "Core/SGCore.h"
+#import "Settings/SGPageStyle.h"
+#import "Haptics.h"
+#import "SGVibrationsPreview.h"
+
+static const NSInteger kRings = 9;
+static const CGFloat kFirstRadius = 15, kRingGap = 10.5;
+static const CGFloat kDotGap = 8.5; // between two dots of a ring, along it
+static const CGFloat kDot = 2.5, kMiddle = 6;
+static const CGFloat kField = 2 * (kFirstRadius + (kRings - 1) * kRingGap) + 24;
+static const CGFloat kCaptionGap = 6, kBottom = 14;
+// How far a full-strength crest pushes the first ring out, how long it takes to reach the next ring, how
+// long a ring takes to settle, and how long it stays lit: short, so the light reads as one ring travelling.
+static const CGFloat kCrest = 6;
+static const CFTimeInterval kRingDelay = 0.05, kCrestLength = 0.6, kLightLength = 0.34;
+// Music Haptics' taps are felt at their own strength; their crest is this much of a tapped one.
+static const CGFloat kPulse = 0.32;
+
+typedef NS_ENUM(NSInteger, Feature) {
+ FeatureControls,
+ FeatureMusic,
+ FeatureNative, // iOS plays Music Haptics itself: nothing to play from here
+ FeatureNone,
+};
+
+static Feature featureNow(void) {
+ if (SGEnabled(SGKeyControlHaptics)) return FeatureControls;
+ switch (SGMusicHapticsModeNow()) {
+ case SGMusicHapticsGenerated: return FeatureMusic;
+ case SGMusicHapticsNative: return FeatureNative;
+ case SGMusicHapticsOff: return FeatureNone;
+ }
+ return FeatureNone;
+}
+
+static NSString *captionFor(Feature feature) {
+ switch (feature) {
+ case FeatureControls: return @"Tap to feel Controls";
+ case FeatureMusic: return @"Tap to feel Music Haptics";
+ case FeatureNative: return @"Native iOS plays on its own. Turn on Controls to feel a tap";
+ case FeatureNone: return @"Turn on Controls or Music Haptics to feel a tap";
+ }
+ return nil;
+}
+
+// What a tap shows of the feature's strength, 0 to 1: Controls' 10 to 100% as it is, Music Haptics' 20 to 200%
+// halved, so its 100% is a middling crest.
+static CGFloat strengthOf(Feature feature) {
+ if (feature == FeatureControls) return SGHapticsStrength(SGKeyControlStrength);
+ if (feature == FeatureMusic) return SGHapticsStrength(SGKeyMusicStrength) / 2;
+ return 0.5;
+}
+
+static CAKeyframeAnimation *keyframes(NSString *path, NSArray *values, NSArray<NSNumber *> *times, CFTimeInterval begin, CFTimeInterval length) {
+ CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:path];
+ animation.values = values;
+ animation.keyTimes = times;
+ animation.timingFunctions = @[[CAMediaTimingFunction functionWithControlPoints:0.23 :1 :0.32 :1],
+ [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
+ [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
+ animation.additive = YES;
+ animation.beginTime = begin;
+ animation.duration = length;
+ // Without this the crest runs at 60 Hz on a ProMotion screen.
+ animation.preferredFrameRateRange = CAFrameRateRangeMake(80, 120, 120);
+ return animation;
+}
+
+@implementation SGVibrationsPreview {
+ CALayer *_field;
+ CALayer *_middle;
+ NSMutableArray<CALayer *> *_dots, *_crests;
+ UILabel *_caption;
+ Feature _feature;
+}
+
+- (instancetype)initWithFrame:(CGRect)frame {
+ if (!(self = [super initWithFrame:frame])) return nil;
+ _field = [CALayer layer];
+ _field.bounds = CGRectMake(0, 0, kField, kField);
+ [self.layer addSublayer:_field];
+ _dots = [NSMutableArray array];
+ _crests = [NSMutableArray array];
+ CGPoint centre = CGPointMake(kField / 2, kField / 2);
+ UIColor *accent = SGGreen();
+ for (NSInteger ring = 0; ring < kRings; ring++) {
+ CGFloat radius = kFirstRadius + ring * kRingGap;
+ NSInteger count = MAX(6, lround(2 * M_PI * radius / kDotGap));
+ CAReplicatorLayer *replicator = [CAReplicatorLayer layer];
+ replicator.frame = _field.bounds;
+ replicator.instanceCount = count;
+ replicator.instanceTransform = CATransform3DMakeRotation(2 * M_PI / count, 0, 0, 1);
+ // Every other ring turned half a step, so the dots weave rather than line up in spokes.
+ replicator.transform = CATransform3DMakeRotation(ring % 2 ? M_PI / count : 0, 0, 0, 1);
+ // Fainter outwards, so the field has no hard edge.
+ CGFloat rest = 0.46 - 0.34 * ring / (kRings - 1);
+ CALayer *dot = [self dotOfSize:kDot colour:UIColor.whiteColor];
+ dot.position = CGPointMake(centre.x + radius, centre.y);
+ dot.opacity = rest;
+ CALayer *crest = [self dotOfSize:kDot colour:accent];
+ crest.position = dot.position;
+ crest.opacity = 0;
+ [replicator addSublayer:dot];
+ [replicator addSublayer:crest];
+ [_field addSublayer:replicator];
+ [_dots addObject:dot];
+ [_crests addObject:crest];
+ }
+ _middle = [self dotOfSize:kMiddle colour:accent];
+ _middle.position = centre;
+ _middle.opacity = 0.9;
+ [_field addSublayer:_middle];
+
+ _caption = [UILabel new];
+ _caption.textColor = SGGrey();
+ _caption.textAlignment = NSTextAlignmentCenter;
+ _caption.numberOfLines = 0;
+ [self addSubview:_caption];
+
+ [self addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(play)]];
+ self.isAccessibilityElement = YES;
+ self.accessibilityTraits = UIAccessibilityTraitButton;
+ self.accessibilityLabel = @"Vibrations preview, rings of dots that ripple out from the middle with each tap";
+ [self reload];
+ return self;
+}
+
+- (CALayer *)dotOfSize:(CGFloat)size colour:(UIColor *)colour {
+ CALayer *dot = [CALayer layer];
+ dot.bounds = CGRectMake(0, 0, size, size);
+ dot.cornerRadius = size / 2;
+ dot.backgroundColor = colour.CGColor;
+ return dot;
+}
+
+- (void)reload {
+ _feature = featureNow();
+ _caption.font = SGSubtitleFont();
+ _caption.text = captionFor(_feature);
+ self.accessibilityHint = _caption.text;
+ [self setNeedsLayout];
+}
+
+- (CGFloat)captionHeightForWidth:(CGFloat)width {
+ return ceil([_caption sizeThatFits:CGSizeMake(width, CGFLOAT_MAX)].height);
+}
+
+- (CGFloat)heightForWidth:(CGFloat)width {
+ return kField + kCaptionGap + [self captionHeightForWidth:width - 2 * self.layoutMargins.left] + kBottom;
+}
+
+- (void)layoutSubviews {
+ [super layoutSubviews];
+ CGFloat width = self.bounds.size.width, inset = self.layoutMargins.left;
+ [CATransaction begin];
+ [CATransaction setDisableActions:YES];
+ _field.position = CGPointMake(width / 2, kField / 2);
+ [CATransaction commit];
+ _caption.frame = CGRectMake(inset, kField + kCaptionGap, width - 2 * inset, [self captionHeightForWidth:width - 2 * inset]);
+}
+
+- (BOOL)accessibilityActivate {
+ [self play];
+ return YES;
+}
+
+// The feature's own tap, through the path it plays from everywhere else, and its crest on the same frame.
+- (void)play {
+ [self reload];
+ switch (_feature) {
+ case FeatureControls: SGPlayFeedback(SGFeedbackAdd); break;
+ case FeatureMusic: SGMusicHapticsPreview(); break;
+ case FeatureNative:
+ case FeatureNone: break;
+ }
+ [self rippleAt:strengthOf(_feature) pressing:YES];
+}
+
+// No finger is on the rings, so the middle stays where it is.
+- (void)rippleAt:(CGFloat)strength {
+ [self rippleAt:strength pressing:NO];
+}
+
+// A crest at `strength`, 0 to 1. A press dips the middle dot first, the way a finger would.
+- (void)rippleAt:(CGFloat)strength pressing:(BOOL)press {
+ if (!self.window) return;
+ strength = MAX(0.05, MIN(1, strength));
+ CFTimeInterval now = [_field convertTime:CACurrentMediaTime() fromLayer:nil];
+ BOOL still = UIAccessibilityIsReduceMotionEnabled();
+ // How many rings the crest carries over before it has lost two thirds of its height.
+ CGFloat reach = 1.5 + 7 * strength;
+ CGFloat light = 0.25 + 0.75 * strength;
+
+ if (still) {
+ for (NSInteger ring = 0; ring < kRings; ring++) {
+ CGFloat fade = exp(-ring / reach);
+ [_crests[ring] addAnimation:keyframes(@"opacity", @[@0, @(0.6 * light * fade), @(0.2 * light * fade), @0], @[@0, @0.3, @0.6, @1], now, 0.6) forKey:nil];
+ }
+ return;
+ }
+ if (press) {
+ // From wherever the last press has it, so taps in a row never jump it.
+ CGFloat from = (_middle.presentationLayer ?: _middle).transform.m11;
+ CAKeyframeAnimation *dip = keyframes(@"transform.scale", @[@(from), @0.6, @(1 + 0.15 * strength), @1], @[@0, @0.25, @0.6, @1], now, 0.36);
+ dip.additive = NO;
+ [_middle addAnimation:dip forKey:@"press"];
+ }
+ for (NSInteger ring = 0; ring < kRings; ring++) {
+ CGFloat fade = exp(-ring / reach);
+ if (fade < 0.04) break;
+ CGFloat push = kCrest * strength * fade;
+ CFTimeInterval begin = now + ring * kRingDelay;
+ // Out past where it rests, a little way back in, then still.
+ NSArray *path = @[@0, @(push), @(-0.3 * push), @0];
+ NSArray<NSNumber *> *times = @[@0, @0.24, @0.58, @1];
+ [_dots[ring] addAnimation:keyframes(@"position.x", path, times, begin, kCrestLength) forKey:nil];
+ [_crests[ring] addAnimation:keyframes(@"position.x", path, times, begin, kCrestLength) forKey:nil];
+ [_crests[ring] addAnimation:keyframes(@"opacity", @[@0, @(light * fade), @(0.2 * light * fade), @0], @[@0, @0.3, @0.6, @1], begin, kLightLength) forKey:nil];
+ [_dots[ring] addAnimation:keyframes(@"opacity", @[@0, @(0.35 * fade), @0, @0], @[@0, @0.3, @0.6, @1], begin, kLightLength) forKey:nil];
+ }
+}
+
+- (void)setListening:(BOOL)listening {
+ if (_listening == listening) return;
+ _listening = listening;
+ if (!listening) {
+ SGMusicHapticsWatchTaps(nil);
+ return;
+ }
+ __weak typeof(self) weakSelf = self;
+ SGMusicHapticsWatchTaps(^(float intensity) {
+ SGVibrationsPreview *preview = weakSelf;
+ // The music's taps are felt anyway; with Reduce Motion they are not also shown.
+ if (!preview || UIAccessibilityIsReduceMotionEnabled()) return;
+ [preview rippleAt:kPulse * intensity pressing:NO];
+ });
+}
+
+// Off screen nothing is left running: the page's listening goes, and any crest still out is dropped.
+- (void)didMoveToWindow {
+ [super didMoveToWindow];
+ if (self.window) return;
+ self.listening = NO;
+ [_middle removeAllAnimations];
+ for (CALayer *dot in _dots) [dot removeAllAnimations];
+ for (CALayer *crest in _crests) [crest removeAllAnimations];
+}
+
+@end