Expand narrated story, preserve solved patterns, and add ambience

Connect the island story with new character memories and narrative transitions.
Blend each solved symbol into its artwork and retain a replayable pattern stamp.
Allow completed grids to be inspected after navigation and app restarts.
Reduce campaign difficulty spikes and keep explained story hints free.

Append 24 narrated continuations while preserving original PCM takes. Add
four offline environmental loops with saved mute/volume controls, scene
fades, narration ducking and lifecycle handling.

Validation: 31 unit/widget tests, Flutter analysis, narration and soundscape
asset checks, tablet discovery layouts and extended-audio integration,
including simultaneous active voice and ambience mixer tracks.
This commit is contained in:
Hadrian Burkhardt
2026-11-02 05:04:57 +01:00
parent 6bd14a9e20
commit 68871ec573
102 changed files with 2322 additions and 520 deletions
+88
View File
@@ -0,0 +1,88 @@
import 'dart:async';
import 'package:audio_session/audio_session.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:just_audio/just_audio.dart';
import 'package:lumen/domain/book.dart';
import 'package:lumen/domain/game.dart';
import 'package:lumen/main.dart';
import 'package:lumen/services/progress.dart';
void main() {
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
testWidgets('extended readings decode and mix with bridge atmosphere', (
tester,
) async {
expect(const bool.fromEnvironment('QA_TEST'), true);
final book = await Book.load();
final session = await AudioSession.instance;
await session.configure(const AudioSessionConfiguration.speech());
final probe = AudioPlayer();
// Exercise the newly added audio, beyond the old recording's endpoint.
for (final track in book.tracks.values.where(
(t) => t['continuation'] != null,
)) {
await probe.setAsset('assets/audio/${track['file']}');
expect(probe.duration!.inMilliseconds, closeTo(track['durationMs'], 5));
final start = Duration(milliseconds: track['cues'].last['startMs']);
await probe.seek(start);
await probe.setVolume(.3);
unawaited(probe.play());
await Future<void>.delayed(const Duration(milliseconds: 350));
expect(probe.position, greaterThanOrEqualTo(start));
expect(probe.processingState, ProcessingState.ready);
await probe.stop();
}
await probe.dispose();
final g = Game(book, Progress.memory({'story_access_level': 11}));
g.briefing(6);
await tester.pumpWidget(LumenApp(game: g, adsEnabled: false));
await tester.pumpAndSettle();
await tester.ensureVisible(find.text('Play this reading'));
await tester.pumpAndSettle();
await tester.tap(find.text('Play this reading'));
await Future<void>.delayed(const Duration(seconds: 2));
await tester.pump();
expect(find.text('Pause recording'), findsOneWidget);
// The host captures AudioFlinger during this interval to verify two real tracks.
debugPrint('MIXED_AUDIO_READY: bridge water and narration');
await Future<void>.delayed(const Duration(seconds: 12));
await tester.tap(find.text('Pause recording'));
await tester.pumpAndSettle();
expect(find.text('Resume recording'), findsOneWidget);
await tester.tap(find.text('Sound & atmosphere'));
await tester.pumpAndSettle();
await tester.tap(find.byType(SwitchListTile));
await tester.pumpAndSettle();
expect(g.progress.flag('ambience_enabled'), false);
await tester.tap(find.text('Keep going'));
await tester.pumpAndSettle();
await tester.tap(find.text('Stop'));
await tester.pumpAndSettle();
// A single Play control carries Mara's unchanged diary into the narrator's
// new continuation and updates the speaker label at the voice boundary.
g.showStory(1);
await tester.pumpAndSettle();
await tester.ensureVisible(find.text('Play this reading'));
await tester.pumpAndSettle();
await tester.tap(find.text('Play this reading'));
final originalMs =
(book.tracks['cottage.window']['originalFrames'] as int) *
1000 ~/
24000;
await Future<void>.delayed(Duration(milliseconds: originalMs + 1800));
await tester.pump();
expect(find.text('Narrator · recorded story'), findsOneWidget);
await tester.tap(find.text('Pause recording'));
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
await binding.convertFlutterSurfaceToImage();
await tester.pump();
await binding.takeScreenshot('expanded-narration-continuation');
await tester.pumpWidget(const SizedBox());
await tester.pumpAndSettle();
});
}