From 6ecb0f56fbb3ff25c52304a87dd38565db5fd8b6 Mon Sep 17 00:00:00 2001 From: larpoux Date: Mon, 16 Sep 2024 21:53:49 +0200 Subject: [PATCH] Dev... --- .gitignore | 50 +- .metadata | 10 + CHANGELOG.md | 3 + README.md | 41 +- analysis_options.yaml | 4 + example/.gitignore | 49 + example/.metadata | 10 + example/README.md | 11 + example/analysis_options.yaml | 4 + example/lib/main.dart | 114 ++ example/pubspec.lock | 235 +++ example/pubspec.yaml | 91 + example/test/widget_test.dart | 30 + lib/src/tauwa_metaclass_implementation.dart | 681 +++++++ lib/src/tauwaweb_audio.dart | 1032 ++++++++++ lib/src/tauwaweb_implementation.dart | 1928 +++++++++++++++++++ lib/tauwaweb.dart | 4 + pubspec.yaml | 57 + test/tauwaweb_test.dart | 12 + 19 files changed, 4340 insertions(+), 26 deletions(-) create mode 100644 .metadata create mode 100644 CHANGELOG.md create mode 100644 analysis_options.yaml create mode 100644 example/.gitignore create mode 100644 example/.metadata create mode 100644 example/README.md create mode 100644 example/analysis_options.yaml create mode 100644 example/lib/main.dart create mode 100644 example/pubspec.lock create mode 100644 example/pubspec.yaml create mode 100644 example/test/widget_test.dart create mode 100644 lib/src/tauwa_metaclass_implementation.dart create mode 100644 lib/src/tauwaweb_audio.dart create mode 100644 lib/src/tauwaweb_implementation.dart create mode 100644 lib/tauwaweb.dart create mode 100644 pubspec.yaml create mode 100644 test/tauwaweb_test.dart diff --git a/.gitignore b/.gitignore index 3a83c2f..ac5aa98 100644 --- a/.gitignore +++ b/.gitignore @@ -1,27 +1,29 @@ -# See https://www.dartlang.org/guides/libraries/private-files +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ -# Files and directories created by pub -.dart_tool/ -.packages -build/ -# If you're building an application, you may want to check-in your pubspec.lock -pubspec.lock - -# Directory created by dartdoc -# If you don't generate documentation locally you can remove this line. -doc/api/ +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ -# dotenv environment variables file -.env* +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ -# Avoid committing generated Javascript files: -*.dart.js -*.info.json # Produced by the --dump-info flag. -*.js # When generated by dart2js. Don't specify *.js if your - # project includes source files written in JavaScript. -*.js_ -*.js.deps -*.js.map - -.flutter-plugins -.flutter-plugins-dependencies +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +build/ diff --git a/.metadata b/.metadata new file mode 100644 index 0000000..24472f1 --- /dev/null +++ b/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "2663184aa79047d0a33a14a3b607954f8fdd8730" + channel: "stable" + +project_type: package diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..41cc7d8 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.0.1 + +* TODO: Describe initial release. diff --git a/README.md b/README.md index 2ad6eec..4a260d8 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,39 @@ -# tauwaweb -The native implementation of the Tauwa interface, running in the web-browser + + +TODO: Put a short description of the package here that helps potential users +know whether this package might be useful for them. + +## Features + +TODO: List what your package can do. Maybe include images, gifs, or videos. + +## Getting started + +TODO: List prerequisites and provide or point to information on how to +start using the package. + +## Usage + +TODO: Include short and useful examples for package users. Add longer examples +to `/example` folder. + +```dart +const like = 'sample'; +``` + +## Additional information + +TODO: Tell users more about the package: where to find more information, how to +contribute to the package, how to file issues, what response they can expect +from the package authors, and more. diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..a5744c1 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/example/.gitignore b/example/.gitignore new file mode 100644 index 0000000..525e05c --- /dev/null +++ b/example/.gitignore @@ -0,0 +1,49 @@ +.DS_Store +.dart_tool/ + +.pub/ + +.idea/ +.vagrant/ +.sconsign.dblite +.svn/ + +migrate_working_dir/ + +*.swp +profile + +DerivedData/ + +.generated/ + +*.pbxuser +*.mode1v3 +*.mode2v3 +*.perspectivev3 + +!default.pbxuser +!default.mode1v3 +!default.mode2v3 +!default.perspectivev3 + +xcuserdata + +*.moved-aside + +*.pyc +*sync/ +Icon? +.tags* + +build/ +.android/ +.ios/ +.flutter-plugins +.flutter-plugins-dependencies + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json diff --git a/example/.metadata b/example/.metadata new file mode 100644 index 0000000..c603270 --- /dev/null +++ b/example/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "2663184aa79047d0a33a14a3b607954f8fdd8730" + channel: "stable" + +project_type: module diff --git a/example/README.md b/example/README.md new file mode 100644 index 0000000..61d30cd --- /dev/null +++ b/example/README.md @@ -0,0 +1,11 @@ +# example + +An example showing how to use the tauwa implementation for the Web. + +## Getting Started + +For help getting started with Flutter development, view the online +[documentation](https://flutter.dev/). + +For instructions integrating Flutter modules to your existing applications, +see the [add-to-app documentation](https://flutter.dev/to/add-to-app). diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml new file mode 100644 index 0000000..a5744c1 --- /dev/null +++ b/example/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/example/lib/main.dart b/example/lib/main.dart new file mode 100644 index 0000000..590d8b0 --- /dev/null +++ b/example/lib/main.dart @@ -0,0 +1,114 @@ +import 'package:flutter/material.dart'; +import 'package:tauwa/tauwa.dart'; +import 'package:tauwaweb/tauwaweb.dart'; + +void main() => runApp(const MyApp()); + +class MyApp extends StatelessWidget { + const MyApp({super.key}); + + // This widget is the root of your application. + @override + Widget build(BuildContext context) { + return MaterialApp( + title: 'Flutter Demo', + theme: ThemeData( + // This is the theme of your application. + // + // Try running your application with "flutter run". You'll see the + // application has a blue toolbar. Then, without quitting the app, try + // changing the primarySwatch below to Colors.green and then invoke + // "hot reload" (press "r" in the console where you ran "flutter run", + // or press Run > Flutter Hot Reload in a Flutter IDE). Notice that the + // counter didn't reset back to zero; the application is not restarted. + primarySwatch: Colors.blue, + ), + home: const MyHomePage(title: 'Flutter Demo Home Page'), + ); + } +} + +class MyHomePage extends StatefulWidget { + const MyHomePage({super.key, required this.title}); + + // This widget is the home page of your application. It is stateful, meaning + // that it has a State object (defined below) that contains fields that affect + // how it looks. + + // This class is the configuration for the state. It holds the values (in this + // case the title) provided by the parent (in this case the App widget) and + // used by the build method of the State. Fields in a Widget subclass are + // always marked "final". + + final String title; + + @override + State createState() => _MyHomePageState(); +} + +class _MyHomePageState extends State { + int _counter = 0; + + void _incrementCounter() { + setState(() { + // This call to setState tells the Flutter framework that something has + // changed in this State, which causes it to rerun the build method below + // so that the display can reflect the updated values. If we changed + // _counter without calling setState(), then the build method would not be + // called again, and so nothing would appear to happen. + _counter++; + }); + } + + @override + Widget build(BuildContext context) { + // This method is rerun every time setState is called, for instance as done + // by the _incrementCounter method above. + // + // The Flutter framework has been optimized to make rerunning build methods + // fast, so that you can just rebuild anything that needs updating rather + // than having to individually change instances of widgets. + return Scaffold( + appBar: AppBar( + // Here we take the value from the MyHomePage object that was created by + // the App.build method, and use it to set our appbar title. + title: Text(widget.title), + ), + body: Center( + // Center is a layout widget. It takes a single child and positions it + // in the middle of the parent. + child: Column( + // Column is also a layout widget. It takes a list of children and + // arranges them vertically. By default, it sizes itself to fit its + // children horizontally, and tries to be as tall as its parent. + // + // Invoke "debug painting" (press "p" in the console, choose the + // "Toggle Debug Paint" action from the Flutter Inspector in Android + // Studio, or the "Toggle Debug Paint" command in Visual Studio Code) + // to see the wireframe for each widget. + // + // Column has various properties to control how it sizes itself and + // how it positions its children. Here we use mainAxisAlignment to + // center the children vertically; the main axis here is the vertical + // axis because Columns are vertical (the cross axis would be + // horizontal). + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text( + 'You have pushed the button this many times:', + ), + Text( + '$_counter', + style: Theme.of(context).textTheme.headlineMedium, + ), + ], + ), + ), + floatingActionButton: FloatingActionButton( + onPressed: _incrementCounter, + tooltip: 'Increment', + child: const Icon(Icons.add), + ), // This trailing comma makes auto-formatting nicer for build methods. + ); + } +} diff --git a/example/pubspec.lock b/example/pubspec.lock new file mode 100644 index 0000000..754615e --- /dev/null +++ b/example/pubspec.lock @@ -0,0 +1,235 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + async: + dependency: transitive + description: + name: async + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" + source: hosted + version: "2.11.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + characters: + dependency: transitive + description: + name: characters + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" + source: hosted + version: "1.3.0" + clock: + dependency: transitive + description: + name: clock + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" + source: hosted + version: "1.1.1" + collection: + dependency: transitive + description: + name: collection + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" + source: hosted + version: "1.18.0" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 + url: "https://pub.dev" + source: hosted + version: "1.0.8" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" + source: hosted + version: "1.3.1" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: "3f41d009ba7172d5ff9be5f6e6e6abb4300e263aab8866d2a0842ed2a70f8f0c" + url: "https://pub.dev" + source: hosted + version: "4.0.0" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" + url: "https://pub.dev" + source: hosted + version: "10.0.5" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" + url: "https://pub.dev" + source: hosted + version: "3.0.5" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" + lints: + dependency: transitive + description: + name: lints + sha256: "976c774dd944a42e83e2467f4cc670daef7eed6295b10b36ae8c85bcbf828235" + url: "https://pub.dev" + source: hosted + version: "4.0.0" + matcher: + dependency: transitive + description: + name: matcher + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + url: "https://pub.dev" + source: hosted + version: "0.12.16+1" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + url: "https://pub.dev" + source: hosted + version: "0.11.1" + meta: + dependency: transitive + description: + name: meta + sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 + url: "https://pub.dev" + source: hosted + version: "1.15.0" + path: + dependency: transitive + description: + name: path + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + url: "https://pub.dev" + source: hosted + version: "1.9.0" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" + source: hosted + version: "1.10.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + url: "https://pub.dev" + source: hosted + version: "1.11.1" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + url: "https://pub.dev" + source: hosted + version: "2.1.2" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + tauwa: + dependency: "direct main" + description: + path: "../../tauwa" + relative: true + source: path + version: "0.0.1" + tauwaweb: + dependency: "direct main" + description: + path: ".." + relative: true + source: path + version: "0.0.1" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" + source: hosted + version: "1.2.1" + test_api: + dependency: transitive + description: + name: test_api + sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" + url: "https://pub.dev" + source: hosted + version: "0.7.2" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" + url: "https://pub.dev" + source: hosted + version: "14.2.5" + web: + dependency: transitive + description: + name: web + sha256: d43c1d6b787bf0afad444700ae7f4db8827f701bc61c255ac8d328c6f4d52062 + url: "https://pub.dev" + source: hosted + version: "1.0.0" +sdks: + dart: ">=3.5.3 <4.0.0" + flutter: ">=3.18.0-18.0.pre.54" diff --git a/example/pubspec.yaml b/example/pubspec.yaml new file mode 100644 index 0000000..f102723 --- /dev/null +++ b/example/pubspec.yaml @@ -0,0 +1,91 @@ +name: example +description: "An example showing how to use the tauwa implementation for the Web." + +# The following defines the version and build number for your application. +# A version number is three numbers separated by dots, like 1.2.43 +# followed by an optional build number separated by a +. +# Both the version and the builder number may be overridden in flutter +# build by specifying --build-name and --build-number, respectively. +# In Android, build-name is used as versionName while build-number used as versionCode. +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning +# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html +# +# This version is used _only_ for the Runner app, which is used if you just do +# a `flutter run` or a `flutter make-host-app-editable`. It has no impact +# on any other native host app that you embed your Flutter project into. +version: 1.0.0+1 + +environment: + sdk: ^3.5.3 + +dependencies: + flutter: + sdk: flutter + tauwa: # ^9.15.61 + path: ../../tauwa # tauwa Dir + tauwaweb: # ^9.15.61 + path: ../ # tauwaweb Dir + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.8 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^4.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +flutter: + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add Flutter specific assets to your application, add an assets section, + # like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/to/resolution-aware-images + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/to/asset-from-package + + # To add Flutter specific custom fonts to your application, add a fonts + # section here, in this "flutter" section. Each entry in this list should + # have a "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/to/font-from-package + + + # This section identifies your Flutter project as a module meant for + # embedding in a native host app. These identifiers should _not_ ordinarily + # be changed after generation - they are used to ensure that the tooling can + # maintain consistency when adding or modifying assets and plugins. + # They also do not have any bearing on your native host application's + # identifiers, which may be completely independent or the same as these. + module: + androidX: true + androidPackage: xyz.canardoux.example + iosBundleIdentifier: xyz.canardoux.example diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart new file mode 100644 index 0000000..092d222 --- /dev/null +++ b/example/test/widget_test.dart @@ -0,0 +1,30 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility in the flutter_test package. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:example/main.dart'; + +void main() { + testWidgets('Counter increments smoke test', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(const MyApp()); + + // Verify that our counter starts at 0. + expect(find.text('0'), findsOneWidget); + expect(find.text('1'), findsNothing); + + // Tap the '+' icon and trigger a frame. + await tester.tap(find.byIcon(Icons.add)); + await tester.pump(); + + // Verify that our counter has incremented. + expect(find.text('0'), findsNothing); + expect(find.text('1'), findsOneWidget); + }); +} diff --git a/lib/src/tauwa_metaclass_implementation.dart b/lib/src/tauwa_metaclass_implementation.dart new file mode 100644 index 0000000..9cc55eb --- /dev/null +++ b/lib/src/tauwa_metaclass_implementation.dart @@ -0,0 +1,681 @@ +/* + * Copyright 2024 Canardoux. + * + * This file is part of the τ project. + * + * τ is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 (GPL3), as published by + * the Free Software Foundation. + * + * τ is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with τ. If not, see . + */ + +import 'package:tauwa/tauwa_metaclass.dart'; +import 'tauwaweb_implementation.dart' as i; + +abstract class tauwa_metaclass_implementation implements tauwa_metaclass +{ + AudioContext newAudioContext([AudioContextOptions contextOptions]) => i.BaseAudioContext(contextOptions); + + + + + AudioContextOptions newAudioContextOptions({ + TauAny latencyHint, + num sampleRate, + TauAny sinkId, + TauAny renderSizeHint, + }) => i.AudioContextOptions(latencyHint: latencyHint, sampleRate: sampleRate, sinkId: sinkId, renderSizeHint: renderSizeHint); + + + + AudioSinkOptions newAudioSinkOptions({required AudioSinkType type}) => i.AudioSinkOptions(type: type); + + + + AudioTimestamp newAudioTimestamp({ + num contextTime, + DOMHighResTimeStamp performanceTime, + }) => i.AudioTimestamp(contextTime: contextTime, performanceTime: performanceTime); + + + + OfflineAudioContext newOfflineAudioContext( + TauAny contextOptionsOrNumberOfChannels, [ + int length, + num sampleRate, + ]) => i.OfflineAudioContext(contextOptionsOrNumberOfChannels, length, sampleRate); + + + + + + OfflineAudioContextOptions newOfflineAudioContextOptions({ + int numberOfChannels, + required int length, + required num sampleRate, + TauAny renderSizeHint, + }) => i.OfflineAudioContextOptions( + numberOfChannels: numberOfChannels, + length: length, + sampleRate: sampleRate, + renderSizeHint: renderSizeHint, + ); + + + + OfflineAudioCompletionEvent newOfflineAudioCompletionEvent( + String type, + OfflineAudioCompletionEventInit eventInitDict, + ) => i.OfflineAudioCompletionEvent(type, eventInitDict); + + + + + OfflineAudioCompletionEventInit newOfflineAudioCompletionEventInit({ + bool bubbles, + bool cancelable, + bool composed, + required AudioBuffer renderedBuffer, + }) => i.OfflineAudioCompletionEventInit(bubbles: bubbles, cancelable: cancelable, composed: composed); + + + + AudioBuffer newAudioBuffer(AudioBufferOptions options) => i.AudioBuffer(options); + + + + + AudioBufferOptions newAudioBufferOptions({ + int numberOfChannels, + required int length, + required num sampleRate, + }) => i.AudioBufferOptions(numberOfChannels: numberOfChannels, length: length, sampleRate: sampleRate); + + + + AudioNodeOptions newAudioNodeOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + }) => i.AudioNodeOptions(channelCount: channelCount, channelCountMode: channelCountMode, channelInterpretation: channelInterpretation); + + + + AnalyserNode newAnalyserNode( + BaseAudioContext context, [ + AnalyserOptions options, + ]) => i.AnalyserNode(context, options); + + + + AnalyserOptions newAnalyserOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + int fftSize, + num maxDecibels, + num minDecibels, + num smoothingTimeConstant, + }) => i.AnalyserOptions( + channelCount: channelCount, + channelCountMode: channelCountMode, + channelInterpretation: channelInterpretation, + fftSize: fftSize, + maxDecibels: maxDecibels, + minDecibels: minDecibels, + smoothingTimeConstant: smoothingTimeConstant, + ); + + + + AudioBufferSourceNode newAudioBufferSourceNode( + BaseAudioContext context, [ + AudioBufferSourceOptions options, + ]) => i.AudioBufferSourceNode(context, options); + + + + + AudioBufferSourceOptions newAudioBufferSourceOptions({ + AudioBuffer? buffer, + num detune, + bool loop, + num loopEnd, + num loopStart, + num playbackRate, + }) => i.AudioBufferSourceOptions( + buffer: buffer, + detune: detune, + loop: loop, + loopEnd: loopEnd, + loopStart: loopStart, + playbackRate: playbackRate, + ); + + + + AudioProcessingEvent newAudioProcessingEvent( + String type, + AudioProcessingEventInit eventInitDict, + ) => i.AudioProcessingEvent(type, eventInitDict); + + + + AudioProcessingEventInit newAudioProcessingEventInit({ + bool bubbles, + bool cancelable, + bool composed, + required num playbackTime, + required AudioBuffer inputBuffer, + required AudioBuffer outputBuffer, + }) => i.AudioProcessingEventInit( + bubbles: bubbles, + cancelable: cancelable, + composed: composed, + playbackTime: playbackTime, + inputBuffer: inputBuffer, + outputBuffer: outputBuffer, + ); + + + + + BiquadFilterNode newBiquadFilterNode( + BaseAudioContext context, [ + BiquadFilterOptions options, + ]) => i.BiquadFilterNode( + context, options + ); + + + + BiquadFilterOptions newBiquadFilterOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + BiquadFilterType type, + num Q, + num detune, + num frequency, + num gain, + }) => i.BiquadFilterOptions( + channelCount: channelCount, + channelCountMode: channelCountMode, + channelInterpretation: channelInterpretation, + type: type, + Q: Q, + detune: detune, + frequency: frequency, + gain: gain, + ); + + + + ChannelMergerNode newChannelMergerNode( + BaseAudioContext context, [ + ChannelMergerOptions options, + ]) => i.ChannelMergerNode( + context, + options, + ); + + + + ChannelMergerOptions newChannelMergerOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + int numberOfInputs, + }) => i.ChannelMergerOptions( + channelCount: channelCount, + channelCountMode: channelCountMode, + channelInterpretation: channelInterpretation, + numberOfInputs: numberOfInputs, + ); + + + + ChannelSplitterNode newChannelSplitterNode( + BaseAudioContext context, [ + ChannelSplitterOptions options, + ]) => i.ChannelSplitterNode( + context, + options, + ); + + + + ChannelSplitterOptions newChannelSplitterOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + int numberOfOutputs, + }) => i.ChannelSplitterOptions( + channelCount: channelCount, + channelCountMode: channelCountMode, + channelInterpretation: channelInterpretation, + numberOfOutputs: numberOfOutputs, + ); + + + + ConstantSourceNode newConstantSourceNode( + BaseAudioContext context, [ + ConstantSourceOptions options, + ]) => i.ConstantSourceNode( + context, + options, + ); + + + + ConstantSourceOption newConstantSourceOptions({num offset}) =>i.ConstantSourceOption(offset: offset); + + + + + ConvolverNode newConvolverNode( + BaseAudioContext context, [ + ConvolverOptions options, + ]) => i.ConstantSourceOption( + context, + options, + ); + + + + ConvolverOptions newConvolverOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + AudioBuffer? buffer, + bool disableNormalization, + }) => i.ConvolverOptions( + channelCount: channelCount, + channelCountMode: channelCountMode, + channelInterpretation: channelInterpretation, + buffer: buffer, + disableNormalization: disableNormalization, + ); + + + + DelayNode newDelayNode( + BaseAudioContext context, [ + DelayOptions options, + ]) => i.DelayNode( + context, + options, + ); + + + + DelayOptions newDelayOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + num maxDelayTime, + num delayTime, + }) => i.DelayOptions( + channelCount: channelCount, + channelCountMode: channelCountMode, + channelInterpretation: channelInterpretation, + maxDelayTime: maxDelayTime, + delayTime: delayTime, + ); + + + + DynamicsCompressorNode newDynamicsCompressorNode( + BaseAudioContext context, [ + DynamicsCompressorOptions options, + ]) => i.DynamicsCompressorNode( + context, + options, + ); + + + + DynamicsCompressorOptions newDynamicsCompressorOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + num attack, + num knee, + num ratio, + num release, + num threshold, + }) => i.DynamicsCompressorOptions( + channelCount: channelCount, + channelCountMode: channelCountMode, + channelInterpretation: channelInterpretation, + attack: attack, + knee: knee, + ratio: ratio, + release: release, + threshold: threshold, + ); + + + + GainNode newGainNode( + BaseAudioContext context, [ + GainOptions options, + ]) => i.GainNode( + context, + options, + ); + + + + GainOptions newGainOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + num gain, + }) => i.GainOptions( + channelCount: channelCount, + channelCountMode: channelCountMode, + channelInterpretation: channelInterpretation, + gain: gain, + ); + + + + IIRFilterNode newIIRFilterNode( + BaseAudioContext context, + IIRFilterOptions options, + ) => i.IIRFilterNode( + context, + options, + ); + + + + IIRFilterOptions newIIRFilterOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + required JSArray feedforward, + required JSArray feedback, + }) => i.IIRFilterOptions( + channelCount: channelCount, + channelCountMode: channelCountMode, + channelInterpretation: channelInterpretation, + feedforward: feedforward, + feedback: feedback + ); + + + + MediaElementAudioSourceNode newMediaElementAudioSourceNode( + AudioContext context, + MediaElementAudioSourceOptions options, + ) => i.MediaElementAudioSourceNode( + context, + options, + ); + + + + MediaElementAudioSourceOptions newMediaElementAudioSourceOptions( + {required HTMLMediaElement mediaElement}) => i.MediaElementAudioSourceOptions( + mediaElement: mediaElement, + ); + + + + + MediaStreamAudioDestinationNode newMediaStreamAudioDestinationNode( + AudioContext context, [ + AudioNodeOptions options, + ]) => i.MediaStreamAudioDestinationNode( + context, + options, + ); + + + + MediaStreamAudioSourceNode newMediaStreamAudioSourceNode( + AudioContext context, + MediaStreamAudioSourceOptions options, + ) => i.MediaStreamAudioSourceNode( + context, + options, + ); + + + + MediaStreamAudioSourceOptions newMediaStreamAudioSourceOptions( + {required MediaStream mediaStream}) => i.MediaStreamAudioSourceOptions( + mediaStream: mediaStream, + ); + + + + + MediaStreamTrackAudioSourceNode newMediaStreamTrackAudioSourceNode( + AudioContext context, + MediaStreamTrackAudioSourceOptions options, + ) => i.MediaStreamTrackAudioSourceNode( + context, + options, + ); + + + + MediaStreamTrackAudioSourceOptions newMediaStreamTrackAudioSourceOptions( + {required MediaStreamTrack mediaStreamTrack}) => i.MediaStreamTrackAudioSourceOptions( + mediaStreamTrack: mediaStreamTrack, + ); + + + + + OscillatorNode newOscillatorNode( + BaseAudioContext context, [ + OscillatorOptions options, + ]) => i.OscillatorNode( + context, + options, + ); + + + + OscillatorOptions newOscillatorOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + OscillatorType type, + num frequency, + num detune, + PeriodicWave periodicWave, + }) => i.OscillatorOptions( + channelCount: channelCount, + channelCountMode: channelCountMode, + channelInterpretation: channelInterpretation, + type: type, + frequency: frequency, + detune: detune, + periodicWave: periodicWave, + ); + + + + PannerNode newPannerNode( + BaseAudioContext context, [ + PannerOptions options, + ]) => i.PannerNode( + context, + options, + ); + + + + + PannerOptions newPannerOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + PanningModelType panningModel, + DistanceModelType distanceModel, + num positionX, + num positionY, + num positionZ, + num orientationX, + num orientationY, + num orientationZ, + num refDistance, + num maxDistance, + num rolloffFactor, + num coneInnerAngle, + num coneOuterAngle, + num coneOuterGain, + }) => i.newPannerOptions( + channelCount: channelCount, + channelCountMode: channelCountMode, + channelInterpretation: channelInterpretation, + panningModel: panningModel, + distanceModel: distanceModel, + positionX: positionX, + positionY: positionY, + positionZ: positionZ, + orientationX: orientationX, + orientationY: orientationY, + orientationZ: orientationZ, + refDistance: refDistance, + maxDistance: maxDistance, + rolloffFactor: rolloffFactor, + coneInnerAngle: coneInnerAngle, + coneOuterAngle: coneOuterAngle, + coneOuterGain: coneOuterGain, + ); + + + + PeriodicWave newPeriodicWave( + BaseAudioContext context, [ + PeriodicWaveOptions options, + ]) => i.PeriodicWave( + context, + options, + ); + + + + PeriodicWaveConstraints newPeriodicWaveConstraints({bool disableNormalization}) => i.PeriodicWaveConstraints(disableNormalization: disableNormalization); + + + + + + PeriodicWaveOptions newPeriodicWaveOptions({ + bool disableNormalization, + JSArray real, + JSArray imag, + }) => i.PeriodicWaveConstraints( + disableNormalization: disableNormalization, + real: real, + imag: imag, + ); + + + + + StereoPannerNode newStereoPannerNode( + BaseAudioContext context, [ + StereoPannerOptions options, + ]) => i.StereoPannerNode( + context, + options, + ); + + + + StereoPannerOptions newStereoPannerOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + num pan, + }) => i.StereoPannerOptions( + channelCount: channelCount, + channelCountMode: channelCountMode, + channelInterpretation: channelInterpretation, + pan: pan, + ); + + + + WaveShaperNode newWaveShaperNode( + BaseAudioContext context, [ + WaveShaperOptions options, + ]) => i.WaveShaperNode( + context, + options, + ); + + + + WaveShaperOptions newWaveShaperOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + JSArray curve, + OverSampleType oversample, + }) => i.WaveShaperOptions( + channelCount: channelCount, + channelCountMode: channelCountMode, + channelInterpretation: channelInterpretation, + curve: curve, + oversample: oversample, + ); + + + + AudioWorkletNode newAudioWorkletNode( + BaseAudioContext context, + String name, [ + AudioWorkletNodeOptions options, + ]) => i.AudioWorkletNode( + context, + name, + options, + ); + + + + AudioWorkletNodeOptions newAudioWorkletNodeOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + int numberOfInputs, + int numberOfOutputs, + JSArray outputChannelCount, + JSObject parameterData, + JSObject processorOptions, + }) => i.AudioWorkletNodeOptions( + channelCount: channelCount, + channelCountMode: channelCountMode, + channelInterpretation: channelInterpretation, + numberOfInputs: numberOfInputs, + numberOfOutputs: numberOfOutputs, + outputChannelCount: outputChannelCount, + parameterData: parameterData, + processorOptions: processorOptions, + ); + + + + AudioWorkletProcessor newAudioWorkletProcessor() => i.AudioWorkletProcessor(); + + + + +} diff --git a/lib/src/tauwaweb_audio.dart b/lib/src/tauwaweb_audio.dart new file mode 100644 index 0000000..290c43a --- /dev/null +++ b/lib/src/tauwaweb_audio.dart @@ -0,0 +1,1032 @@ +/* + * Copyright 2024 Canardoux. + * + * This file is part of the τ project. + * + * τ is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 (GPL3), as published by + * the Free Software Foundation. + * + * τ is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with τ. If not, see . + */ + + +@JS() +library; + +import 'dart:js_interop'; +import 'dart:html'; +import 'dart:js'; +import 'dart:js_util'; +import 'dart:web_audio'; +import 'package:web/web.dart'; +import 'package:tauwa/tauwa.dart' as t; + +//import 'package:js/js.dart'; +//import 'dart:dom'; +//import 'dart:dom.dart'; +//import 'dart:hr_time.dart'; +//import 'dart:html'; +//import 'mediacapture_streams.dart'; + +typedef DecodeErrorCallback = JSFunction; +typedef DecodeSuccessCallback = JSFunction; +typedef AudioWorkletProcessorConstructor = JSFunction; +typedef AudioContextState = String; +typedef AudioContextRenderSizeCategory = String; +typedef AudioContextLatencyCategory = String; +typedef AudioSinkType = String; +typedef ChannelCountMode = String; +typedef ChannelInterpretation = String; +typedef AutomationRate = String; +typedef BiquadFilterType = String; +typedef OscillatorType = String; +typedef PanningModelType = String; +typedef DistanceModelType = String; +typedef OverSampleType = String; + +extension type BaseAudioContext._(JSObject _) implements JSObject { + external AnalyserNode createAnalyser(); + external BiquadFilterNode createBiquadFilter(); + external AudioBuffer createBuffer( + int numberOfChannels, + int length, + num sampleRate, + ); + + external AudioBufferSourceNode createBufferSource(); + external ChannelMergerNode createChannelMerger([int numberOfInputs]); + external ChannelSplitterNode createChannelSplitter([int numberOfOutputs]); + external ConstantSourceNode createConstantSource(); + external ConvolverNode createConvolver(); + external DelayNode createDelay([num maxDelayTime]); + external DynamicsCompressorNode createDynamicsCompressor(); + external GainNode createGain(); + external IIRFilterNode createIIRFilter( + JSArray feedforward, + JSArray feedback, + ); + external OscillatorNode createOscillator(); + external PannerNode createPanner(); + external PeriodicWave createPeriodicWave( + JSArray real, + JSArray imag, [ + PeriodicWaveConstraints constraints, + ]); + external ScriptProcessorNode createScriptProcessor([ + int bufferSize, + int numberOfInputChannels, + int numberOfOutputChannels, + ]); + external StereoPannerNode createStereoPanner(); + external WaveShaperNode createWaveShaper(); + external JSPromise decodeAudioData( + JSArrayBuffer audioData, [ + DecodeSuccessCallback? successCallback, + DecodeErrorCallback? errorCallback, + ]); + external AudioDestinationNode get destination; + external double get sampleRate; + external double get currentTime; + external AudioListener get listener; + external AudioContextState get state; + external AudioWorklet get audioWorklet; + external EventHandler get onstatechange; + external set onstatechange(EventHandler value); +} + +extension type AudioContext._(JSObject _) + implements BaseAudioContext, JSObject { + external factory AudioContext([AudioContextOptions contextOptions]); + external AudioTimestamp getOutputTimestamp(); + external JSPromise resume(); + external JSPromise suspend(); + external JSPromise close(); + external MediaElementAudioSourceNode createMediaElementSource( + HTMLMediaElement mediaElement); + external MediaStreamAudioSourceNode createMediaStreamSource( + MediaStream mediaStream); + external MediaStreamTrackAudioSourceNode createMediaStreamTrackSource( + MediaStreamTrack mediaStreamTrack); + external MediaStreamAudioDestinationNode createMediaStreamDestination(); + external double get baseLatency; + external double get outputLatency; +} + +extension type AudioContextOptions._(JSObject _) implements JSObject { + external factory AudioContextOptions({ + JSAny latencyHint, + num sampleRate, + JSAny sinkId, + JSAny renderSizeHint, + }); + + external JSAny get latencyHint; + external set latencyHint(JSAny value); + external double get sampleRate; + external set sampleRate(num value); + external JSAny get sinkId; + external set sinkId(JSAny value); + external JSAny get renderSizeHint; + external set renderSizeHint(JSAny value); +} +extension type AudioSinkOptions._(JSObject _) implements JSObject { + external factory AudioSinkOptions({required AudioSinkType type}); + + external AudioSinkType get type; + external set type(AudioSinkType value); +} +extension type AudioTimestamp._(JSObject _) implements JSObject { + external factory AudioTimestamp({ + num contextTime, + DOMHighResTimeStamp performanceTime, + }); + + external double get contextTime; + external set contextTime(num value); + external double get performanceTime; + external set performanceTime(DOMHighResTimeStamp value); +} + + +extension type OfflineAudioContext._(JSObject _) + implements BaseAudioContext, JSObject { + external factory OfflineAudioContext( + JSAny contextOptionsOrNumberOfChannels, [ + int length, + num sampleRate, + ]); + external JSPromise startRendering(); + external JSPromise resume(); + external JSPromise suspend(num suspendTime); + external int get length; + external EventHandler get oncomplete; + external set oncomplete(EventHandler value); +} + +extension type OfflineAudioContextOptions._(JSObject _) implements JSObject { + external factory OfflineAudioContextOptions({ + int numberOfChannels, + required int length, + required num sampleRate, + JSAny renderSizeHint, + }); + + external int get numberOfChannels; + external set numberOfChannels(int value); + external int get length; + external set length(int value); + external double get sampleRate; + external set sampleRate(num value); + external JSAny get renderSizeHint; + external set renderSizeHint(JSAny value); +} + +extension type OfflineAudioCompletionEvent._(JSObject _) + implements Event, JSObject { + external factory OfflineAudioCompletionEvent( + String type, + OfflineAudioCompletionEventInit eventInitDict, + ); + external AudioBuffer get renderedBuffer; +} + +extension type OfflineAudioCompletionEventInit._(JSObject _) + implements EventInit, JSObject { + external factory OfflineAudioCompletionEventInit({ + bool bubbles, + bool cancelable, + bool composed, + required AudioBuffer renderedBuffer, + }); + + external AudioBuffer get renderedBuffer; + external set renderedBuffer(AudioBuffer value); +} + +extension type AudioBuffer._(JSObject _) implements JSObject { + external factory AudioBuffer(AudioBufferOptions options); + external JSFloat32Array getChannelData(int channel); + external void copyFromChannel( + JSFloat32Array destination, + int channelNumber, [ + int bufferOffset, + ]); + external void copyToChannel( + JSFloat32Array source, + int channelNumber, [ + int bufferOffset, + ]); + external double get sampleRate; + external int get length; + external double get duration; + external int get numberOfChannels; +} +extension type AudioBufferOptions._(JSObject _) implements JSObject { + external factory AudioBufferOptions({ + int numberOfChannels, + required int length, + required num sampleRate, + }); + + external int get numberOfChannels; + external set numberOfChannels(int value); + external int get length; + external set length(int value); + external double get sampleRate; + external set sampleRate(num value); +} + +extension type AudioNode._(JSObject _) implements EventTarget, JSObject { + external AudioNode? connect( + JSObject destinationNodeOrDestinationParam, [ + int output, + int input, + ]); + external void disconnect([ + JSAny destinationNodeOrDestinationParamOrOutput, + int output, + int input, + ]); + external BaseAudioContext get context; + external int get numberOfInputs; + external int get numberOfOutputs; + external int get channelCount; + external set channelCount(int value); + external ChannelCountMode get channelCountMode; + external set channelCountMode(ChannelCountMode value); + external ChannelInterpretation get channelInterpretation; + external set channelInterpretation(ChannelInterpretation value); +} +extension type AudioNodeOptions._(JSObject _) implements JSObject { + external factory AudioNodeOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + }); + + external int get channelCount; + external set channelCount(int value); + external ChannelCountMode get channelCountMode; + external set channelCountMode(ChannelCountMode value); + external ChannelInterpretation get channelInterpretation; + external set channelInterpretation(ChannelInterpretation value); +} + +extension type AudioParam._(JSObject _) implements JSObject { + external AudioParam setValueAtTime( + num value, + num startTime, + ); + external AudioParam linearRampToValueAtTime( + num value, + num endTime, + ); + external AudioParam exponentialRampToValueAtTime( + num value, + num endTime, + ); + external AudioParam setTargetAtTime( + num target, + num startTime, + num timeConstant, + ); + external AudioParam setValueCurveAtTime( + JSArray values, + num startTime, + num duration, + ); + external AudioParam cancelScheduledValues(num cancelTime); + external AudioParam cancelAndHoldAtTime(num cancelTime); + external double get value; + external set value(num value); + external AutomationRate get automationRate; + external set automationRate(AutomationRate value); + external double get defaultValue; + external double get minValue; + external double get maxValue; +} + +extension type AudioScheduledSourceNode._(JSObject _) + implements AudioNode, JSObject { + external void start([num when]); + external void stop([num when]); + external EventHandler get onended; + external set onended(EventHandler value); +} + +extension type AnalyserNode._(JSObject _) implements AudioNode, JSObject { + external factory AnalyserNode( + BaseAudioContext context, [ + AnalyserOptions options, + ]); + + external void getFloatFrequencyData(JSFloat32Array array); + external void getByteFrequencyData(JSUint8Array array); + external void getFloatTimeDomainData(JSFloat32Array array); + external void getByteTimeDomainData(JSUint8Array array); + external int get fftSize; + external set fftSize(int value); + external int get frequencyBinCount; + external double get minDecibels; + external set minDecibels(num value); + external double get maxDecibels; + external set maxDecibels(num value); + external double get smoothingTimeConstant; + external set smoothingTimeConstant(num value); +} +extension type AnalyserOptions._(JSObject _) + implements AudioNodeOptions, JSObject { + external factory AnalyserOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + int fftSize, + num maxDecibels, + num minDecibels, + num smoothingTimeConstant, + }); + + external int get fftSize; + external set fftSize(int value); + external double get maxDecibels; + external set maxDecibels(num value); + external double get minDecibels; + external set minDecibels(num value); + external double get smoothingTimeConstant; + external set smoothingTimeConstant(num value); +} + +extension type AudioBufferSourceNode._(JSObject _) + implements AudioScheduledSourceNode, JSObject { + external factory AudioBufferSourceNode( + BaseAudioContext context, [ + AudioBufferSourceOptions options, + ]); + external void start([ + num when, + num offset, + num duration, + ]); + external AudioBuffer? get buffer; + external set buffer(AudioBuffer? value); + external AudioParam get playbackRate; + external AudioParam get detune; + external bool get loop; + external set loop(bool value); + external double get loopStart; + external set loopStart(num value); + external double get loopEnd; + external set loopEnd(num value); +} +extension type AudioBufferSourceOptions._(JSObject _) implements JSObject { + external factory AudioBufferSourceOptions({ + AudioBuffer? buffer, + num detune, + bool loop, + num loopEnd, + num loopStart, + num playbackRate, + }); + + external AudioBuffer? get buffer; + external set buffer(AudioBuffer? value); + external double get detune; + external set detune(num value); + external bool get loop; + external set loop(bool value); + external double get loopEnd; + external set loopEnd(num value); + external double get loopStart; + external set loopStart(num value); + external double get playbackRate; + external set playbackRate(num value); +} + +extension type AudioDestinationNode._(JSObject _) + implements AudioNode, JSObject { + external int get maxChannelCount; +} + +extension type AudioListener._(JSObject _) implements JSObject { + external void setPosition( + num x, + num y, + num z, + ); + + external void setOrientation( + num x, + num y, + num z, + num xUp, + num yUp, + num zUp, + ); + external AudioParam get positionX; + external AudioParam get positionY; + external AudioParam get forwardX; + external AudioParam get forwardY; + external AudioParam get forwardZ; + external AudioParam get upX; + external AudioParam get upY; + external AudioParam get upZ; +} + +extension type AudioProcessingEvent._(JSObject _) implements Event, JSObject { + external factory AudioProcessingEvent( + String type, + AudioProcessingEventInit eventInitDict, + ); + + external double get playbackTime; + external AudioBuffer get inputBuffer; + external AudioBuffer get outputBuffer; +} +extension type AudioProcessingEventInit._(JSObject _) + implements EventInit, JSObject { + external factory AudioProcessingEventInit({ + bool bubbles, + bool cancelable, + bool composed, + required num playbackTime, + required AudioBuffer inputBuffer, + required AudioBuffer outputBuffer, + }); + + external double get playbackTime; + external set playbackTime(num value); + external AudioBuffer get inputBuffer; + external set inputBuffer(AudioBuffer value); + external AudioBuffer get outputBuffer; + external set outputBuffer(AudioBuffer value); +} + +extension type BiquadFilterNode._(JSObject _) implements AudioNode, JSObject { + external factory BiquadFilterNode( + BaseAudioContext context, [ + BiquadFilterOptions options, + ]); + external void getFrequencyResponse( + JSFloat32Array frequencyHz, + JSFloat32Array magResponse, + JSFloat32Array phaseResponse, + ); + external BiquadFilterType get type; + external set type(BiquadFilterType value); + external AudioParam get frequency; + external AudioParam get detune; + external AudioParam get Q; + external AudioParam get gain; +} +extension type BiquadFilterOptions._(JSObject _) + implements AudioNodeOptions, JSObject { + external factory BiquadFilterOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + BiquadFilterType type, + num Q, + num detune, + num frequency, + num gain, + }); + + external BiquadFilterType get type; + external set type(BiquadFilterType value); + external double get Q; + external set Q(num value); + external double get detune; + external set detune(num value); + external double get frequency; + external set frequency(num value); + external double get gain; + external set gain(num value); +} + +extension type ChannelMergerNode._(JSObject _) implements AudioNode, JSObject { + external factory ChannelMergerNode( + BaseAudioContext context, [ + ChannelMergerOptions options, + ]); +} +extension type ChannelMergerOptions._(JSObject _) + implements AudioNodeOptions, JSObject { + external factory ChannelMergerOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + int numberOfInputs, + }); + + external int get numberOfInputs; + external set numberOfInputs(int value); +} + +extension type ChannelSplitterNode._(JSObject _) + implements AudioNode, JSObject { + external factory ChannelSplitterNode( + BaseAudioContext context, [ + ChannelSplitterOptions options, + ]); +} +extension type ChannelSplitterOptions._(JSObject _) + implements AudioNodeOptions, JSObject { + external factory ChannelSplitterOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + int numberOfOutputs, + }); + + external int get numberOfOutputs; + external set numberOfOutputs(int value); +} + +extension type ConstantSourceNode._(JSObject _) + implements AudioScheduledSourceNode, JSObject { + external factory ConstantSourceNode( + BaseAudioContext context, [ + ConstantSourceOptions options, + ]); + external AudioParam get offset; +} +extension type ConstantSourceOptions._(JSObject _) implements JSObject { + external factory ConstantSourceOptions({num offset}); + + external double get offset; + external set offset(num value); +} + +extension type ConvolverNode._(JSObject _) implements AudioNode, JSObject { + external factory ConvolverNode( + BaseAudioContext context, [ + ConvolverOptions options, + ]); + + external AudioBuffer? get buffer; + external set buffer(AudioBuffer? value); + external bool get normalize; + external set normalize(bool value); +} +extension type ConvolverOptions._(JSObject _) + implements AudioNodeOptions, JSObject { + external factory ConvolverOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + AudioBuffer? buffer, + bool disableNormalization, + }); + + external AudioBuffer? get buffer; + external set buffer(AudioBuffer? value); + external bool get disableNormalization; + external set disableNormalization(bool value); +} +extension type DelayNode._(JSObject _) implements AudioNode, JSObject { + external factory DelayNode( + BaseAudioContext context, [ + DelayOptions options, + ]); + + external AudioParam get delayTime; +} +extension type DelayOptions._(JSObject _) + implements AudioNodeOptions, JSObject { + external factory DelayOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + num maxDelayTime, + num delayTime, + }); + + external double get maxDelayTime; + external set maxDelayTime(num value); + external double get delayTime; + external set delayTime(num value); +} + +extension type DynamicsCompressorNode._(JSObject _) + implements AudioNode, JSObject { + external factory DynamicsCompressorNode( + BaseAudioContext context, [ + DynamicsCompressorOptions options, + ]); + + external AudioParam get threshold; + external AudioParam get knee; + external AudioParam get ratio; + external double get reduction; + external AudioParam get attack; + external AudioParam get release; +} +extension type DynamicsCompressorOptions._(JSObject _) + implements AudioNodeOptions, JSObject { + external factory DynamicsCompressorOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + num attack, + num knee, + num ratio, + num release, + num threshold, + }); + + external double get attack; + external set attack(num value); + external double get knee; + external set knee(num value); + external double get ratio; + external set ratio(num value); + external double get release; + external set release(num value); + external double get threshold; + external set threshold(num value); +} + +extension type GainNode._(JSObject _) implements AudioNode, JSObject { + external factory GainNode( + BaseAudioContext context, [ + GainOptions options, + ]); + external AudioParam get gain; +} + +/* +extension type titi._(t.GainNode _) implements t.GainNode, GainNode { + +} + + */ +/* +class toto implements t.GainNode +{ + GainNode delegate; + factory toto( + BaseAudioContext context, [ + GainOptions options, + ]) {delegate = GainNode(context, option);} +} + + */ + +extension type GainOptions._(JSObject _) implements AudioNodeOptions, JSObject { + external factory GainOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + num gain, + }); + + external double get gain; + external set gain(num value); +} + +extension type IIRFilterNode._(JSObject _) implements AudioNode, JSObject { + external factory IIRFilterNode( + BaseAudioContext context, + IIRFilterOptions options, + ); + + external void getFrequencyResponse( + JSFloat32Array frequencyHz, + JSFloat32Array magResponse, + JSFloat32Array phaseResponse, + ); +} +extension type IIRFilterOptions._(JSObject _) + implements AudioNodeOptions, JSObject { + external factory IIRFilterOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + required JSArray feedforward, + required JSArray feedback, + }); + + external JSArray get feedforward; + external set feedforward(JSArray value); + external JSArray get feedback; + external set feedback(JSArray value); +} + +extension type MediaElementAudioSourceNode._(JSObject _) + implements AudioNode, JSObject { + external factory MediaElementAudioSourceNode( + AudioContext context, + MediaElementAudioSourceOptions options, + ); + + external HTMLMediaElement get mediaElement; +} +extension type MediaElementAudioSourceOptions._(JSObject _) + implements JSObject { + external factory MediaElementAudioSourceOptions( + {required HTMLMediaElement mediaElement}); + + external HTMLMediaElement get mediaElement; + external set mediaElement(HTMLMediaElement value); +} + +extension type MediaStreamAudioDestinationNode._(JSObject _) + implements AudioNode, JSObject { + external factory MediaStreamAudioDestinationNode( + AudioContext context, [ + AudioNodeOptions options, + ]); + external MediaStream get stream; +} + +extension type MediaStreamAudioSourceNode._(JSObject _) + implements AudioNode, JSObject { + external factory MediaStreamAudioSourceNode( + AudioContext context, + MediaStreamAudioSourceOptions options, + ); + + external MediaStream get mediaStream; +} +extension type MediaStreamAudioSourceOptions._(JSObject _) implements JSObject { + external factory MediaStreamAudioSourceOptions( + {required MediaStream mediaStream}); + + external MediaStream get mediaStream; + external set mediaStream(MediaStream value); +} +extension type MediaStreamTrackAudioSourceNode._(JSObject _) + implements AudioNode, JSObject { + external factory MediaStreamTrackAudioSourceNode( + AudioContext context, + MediaStreamTrackAudioSourceOptions options, + ); +} +extension type MediaStreamTrackAudioSourceOptions._(JSObject _) + implements JSObject { + external factory MediaStreamTrackAudioSourceOptions( + {required MediaStreamTrack mediaStreamTrack}); + + external MediaStreamTrack get mediaStreamTrack; + external set mediaStreamTrack(MediaStreamTrack value); +} + +extension type OscillatorNode._(JSObject _) + implements AudioScheduledSourceNode, JSObject { + external factory OscillatorNode( + BaseAudioContext context, [ + OscillatorOptions options, + ]); + external void setPeriodicWave(PeriodicWave periodicWave); + external OscillatorType get type; + external set type(OscillatorType value); + external AudioParam get frequency; + external AudioParam get detune; +} +extension type OscillatorOptions._(JSObject _) + implements AudioNodeOptions, JSObject { + external factory OscillatorOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + OscillatorType type, + num frequency, + num detune, + PeriodicWave periodicWave, + }); + + external OscillatorType get type; + external set type(OscillatorType value); + external double get frequency; + external set frequency(num value); + external double get detune; + external set detune(num value); + external PeriodicWave get periodicWave; + external set periodicWave(PeriodicWave value); +} + +extension type PannerNode._(JSObject _) implements AudioNode, JSObject { + external factory PannerNode( + BaseAudioContext context, [ + PannerOptions options, + ]); + external void setPosition( + num x, + num y, + num z, + ); + external void setOrientation( + num x, + num y, + num z, + ); + external PanningModelType get panningModel; + external set panningModel(PanningModelType value); + external AudioParam get positionX; + external AudioParam get positionY; + external AudioParam get positionZ; + external AudioParam get orientationX; + external AudioParam get orientationY; + external AudioParam get orientationZ; + external DistanceModelType get distanceModel; + external set distanceModel(DistanceModelType value); + external double get refDistance; + external set refDistance(num value); + external double get maxDistance; + external set maxDistance(num value); + external double get rolloffFactor; + external set rolloffFactor(num value); + external double get coneInnerAngle; + external set coneInnerAngle(num value); + external double get coneOuterAngle; + external set coneOuterAngle(num value); + external double get coneOuterGain; + external set coneOuterGain(num value); +} +extension type PannerOptions._(JSObject _) + implements AudioNodeOptions, JSObject { + external factory PannerOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + PanningModelType panningModel, + DistanceModelType distanceModel, + num positionX, + num positionY, + num positionZ, + num orientationX, + num orientationY, + num orientationZ, + num refDistance, + num maxDistance, + num rolloffFactor, + num coneInnerAngle, + num coneOuterAngle, + num coneOuterGain, + }); + + external PanningModelType get panningModel; + external set panningModel(PanningModelType value); + external DistanceModelType get distanceModel; + external set distanceModel(DistanceModelType value); + external double get positionX; + external set positionX(num value); + external double get positionY; + external set positionY(num value); + external double get positionZ; + external set positionZ(num value); + external double get orientationX; + external set orientationX(num value); + external double get orientationY; + external set orientationY(num value); + external double get orientationZ; + external set orientationZ(num value); + external double get refDistance; + external set refDistance(num value); + external double get maxDistance; + external set maxDistance(num value); + external double get rolloffFactor; + external set rolloffFactor(num value); + external double get coneInnerAngle; + external set coneInnerAngle(num value); + external double get coneOuterAngle; + external set coneOuterAngle(num value); + external double get coneOuterGain; + external set coneOuterGain(num value); +} +extension type PeriodicWave._(JSObject _) implements JSObject { + external factory PeriodicWave( + BaseAudioContext context, [ + PeriodicWaveOptions options, + ]); +} +extension type PeriodicWaveConstraints._(JSObject _) implements JSObject { + external factory PeriodicWaveConstraints({bool disableNormalization}); + + external bool get disableNormalization; + external set disableNormalization(bool value); +} +extension type PeriodicWaveOptions._(JSObject _) + implements PeriodicWaveConstraints, JSObject { + external factory PeriodicWaveOptions({ + bool disableNormalization, + JSArray real, + JSArray imag, + }); + + external JSArray get real; + external set real(JSArray value); + external JSArray get imag; + external set imag(JSArray value); +} + +extension type ScriptProcessorNode._(JSObject _) + implements AudioNode, JSObject { + external EventHandler get onaudioprocess; + external set onaudioprocess(EventHandler value); + external int get bufferSize; +} + +extension type StereoPannerNode._(JSObject _) implements AudioNode, JSObject { + external factory StereoPannerNode( + BaseAudioContext context, [ + StereoPannerOptions options, + ]); + external AudioParam get pan; +} +extension type StereoPannerOptions._(JSObject _) + implements AudioNodeOptions, JSObject { + external factory StereoPannerOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + num pan, + }); + + external double get pan; + external set pan(num value); +} +extension type WaveShaperNode._(JSObject _) implements AudioNode, JSObject { + external factory WaveShaperNode( + BaseAudioContext context, [ + WaveShaperOptions options, + ]); + external JSFloat32Array? get curve; + external set curve(JSFloat32Array? value); + external OverSampleType get oversample; + external set oversample(OverSampleType value); +} +extension type WaveShaperOptions._(JSObject _) + implements AudioNodeOptions, JSObject { + external factory WaveShaperOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + JSArray curve, + OverSampleType oversample, + }); + + external JSArray get curve; + external set curve(JSArray value); + external OverSampleType get oversample; + external set oversample(OverSampleType value); +} +extension type AudioWorklet._(JSObject _) implements Worklet, JSObject {} +extension type AudioWorkletGlobalScope._(JSObject _) + implements WorkletGlobalScope, JSObject { + external void registerProcessor( + String name, + AudioWorkletProcessorConstructor processorCtor, + ); + external int get currentFrame; + external double get currentTime; + external double get sampleRate; +} +extension type AudioParamMap._(JSObject _) implements JSObject {} +extension type AudioWorkletNode._(JSObject _) implements AudioNode, JSObject { + external factory AudioWorkletNode( + BaseAudioContext context, + String name, [ + AudioWorkletNodeOptions options, + ]); + external AudioParamMap get parameters; + external MessagePort get port; + external EventHandler get onprocessorerror; + external set onprocessorerror(EventHandler value); +} +extension type AudioWorkletNodeOptions._(JSObject _) + implements AudioNodeOptions, JSObject { + external factory AudioWorkletNodeOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + int numberOfInputs, + int numberOfOutputs, + JSArray outputChannelCount, + JSObject parameterData, + JSObject processorOptions, + }); + + external int get numberOfInputs; + external set numberOfInputs(int value); + external int get numberOfOutputs; + external set numberOfOutputs(int value); + external JSArray get outputChannelCount; + external set outputChannelCount(JSArray value); + external JSObject get parameterData; + external set parameterData(JSObject value); + external JSObject get processorOptions; + external set processorOptions(JSObject value); +} + +extension type AudioWorkletProcessor._(JSObject _) implements JSObject { + external factory AudioWorkletProcessor(); + external MessagePort get port; +} diff --git a/lib/src/tauwaweb_implementation.dart b/lib/src/tauwaweb_implementation.dart new file mode 100644 index 0000000..5ddc1d8 --- /dev/null +++ b/lib/src/tauwaweb_implementation.dart @@ -0,0 +1,1928 @@ +/* + * Copyright 2024 Canardoux. + * + * This file is part of the τ project. + * + * τ is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 (GPL3), as published by + * the Free Software Foundation. + * + * τ is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with τ. If not, see . + */ + +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// +// API docs from [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web). +// Attributions and copyright licensing by Mozilla Contributors is licensed +// under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/. + +// Generated from Web IDL definitions. + +// ignore_for_file: unintended_html_in_doc_comment + +library; + +import 'dart:typed_data'; +import 'package:tauwa/tauwa.dart' as t; + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +abstract class BaseAudioContext implements t.BaseAudioContext { + AnalyserNode createAnalyser(); + BiquadFilterNode createBiquadFilter(); + AudioBuffer createBuffer( + int numberOfChannels, + int length, + num sampleRate, + ); + + AudioBufferSourceNode createBufferSource(); + ChannelMergerNode createChannelMerger([int numberOfInputs]); + ChannelSplitterNode createChannelSplitter([int numberOfOutputs]); + ConstantSourceNode createConstantSource(); + ConvolverNode createConvolver(); + DelayNode createDelay([num maxDelayTime]); + DynamicsCompressorNode createDynamicsCompressor(); + GainNode createGain(); + IIRFilterNode createIIRFilter( + TauArray feedforward, + TauArray feedback, + ); + OscillatorNode createOscillator(); + PannerNode createPanner(); + PeriodicWave createPeriodicWave( + TauArray real, + TauArray imag, [ + PeriodicWaveConstraints constraints, + ]); + ScriptProcessorNode createScriptProcessor([ + int bufferSize, + int numberOfInputChannels, + int numberOfOutputChannels, + ]); + StereoPannerNode createStereoPanner(); + WaveShaperNode createWaveShaper(); + TauPromise decodeAudioData( + TauArrayBuffer audioData, [ + DecodeSuccessCallback? successCallback, + DecodeErrorCallback? errorCallback, + ]); + AudioDestinationNode get destination; + double get sampleRate; + double get currentTime; + AudioListener get listener; + AudioContextState get state; + AudioWorklet get audioWorklet; + EventHandler get onstatechange; + set onstatechange(EventHandler value); +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class AudioContext extends BaseAudioContext implements t.AudioContext { + + AudioContext newAudioContext([AudioContextOptions contextOptions]) => BaseAudioContext(contextOptions); + + AudioTimestamp getOutputTimestamp(); + TauPromise resume(); + TauPromise suspend(); + TauPromise close(); + MediaElementAudioSourceNode createMediaElementSource( + HTMLMediaElement mediaElement); + MediaStreamAudioSourceNode createMediaStreamSource( + MediaStream mediaStream); + MediaStreamTrackAudioSourceNode createMediaStreamTrackSource( + MediaStreamTrack mediaStreamTrack); + MediaStreamAudioDestinationNode createMediaStreamDestination(); + double get baseLatency; + double get outputLatency; +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + +class AudioContextOptions implements t.AudioContextOptions { + + AudioContextOptions newAudioContextOptions({ + TauAny latencyHint, + num sampleRate, + TauAny sinkId, + TauAny renderSizeHint, + }) => AudioContextOptions(latencyHint: latencyHint, sampleRate: sampleRate, sinkId: sinkId, renderSizeHint: renderSizeHint); + + TauAny get latencyHint; + set latencyHint(TauAny value); + double get sampleRate; + set sampleRate(num value); + TauAny get sinkId; + set sinkId(TauAny value); + TauAny get renderSizeHint; + set renderSizeHint(TauAny value); +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + +class AudioSinkOptions implements t.AudioSinkOptions { + + AudioSinkOptions newAudioSinkOptions({required AudioSinkType type}) => AudioSinkOptions(type: type); + + AudioSinkType get type; + set type(AudioSinkType value); +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + + +class AudioTimestamp implements t.AudioTimestamp{ + + AudioTimestamp newAudioTimestamp({ + num contextTime, + DOMHighResTimeStamp performanceTime, + }) => AudioTimestamp(contextTime: contextTime, performanceTime: performanceTime); + + double get contextTime; + set contextTime(num value); + double get performanceTime; + set performanceTime(TauHighResTimeStamp value); +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class OfflineAudioContext extends BaseAudioContext implements t.OfflineAudioContext { + + OfflineAudioContext newOfflineAudioContext( + TauAny contextOptionsOrNumberOfChannels, [ + int length, + num sampleRate, + ]) => OfflineAudioContext(contextOptionsOrNumberOfChannels, length, sampleRate); + + TauPromise startRendering(); + TauPromise resume(); + TauPromise suspend(num suspendTime); + int get length; + EventHandler get oncomplete; + set oncomplete(EventHandler value); +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class OfflineAudioContextOptions implements t.OfflineAudioContextOptions { + + OfflineAudioContextOptions newOfflineAudioContextOptions({ + int numberOfChannels, + required int length, + required num sampleRate, + TauAny renderSizeHint, + }) => OfflineAudioContextOptions( + numberOfChannels: numberOfChannels, + length: length, + sampleRate: sampleRate, + renderSizeHint: renderSizeHint, + ); + + int get numberOfChannels; + set numberOfChannels(int value); + int get length; + set length(int value); + double get sampleRate; + set sampleRate(num value); + TauAny get renderSizeHint; + set renderSizeHint(TauAny value); +} + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class OfflineAudioCompletionEvent implements t.OfflineAudioCompletionEvent { + + OfflineAudioCompletionEvent newOfflineAudioCompletionEvent( + String type, + OfflineAudioCompletionEventInit eventInitDict, + ) => OfflineAudioCompletionEvent(type, eventInitDict); + + + AudioBuffer get renderedBuffer; +} + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class OfflineAudioCompletionEventInit implements t.OfflineAudioCompletionEventInit { + + OfflineAudioCompletionEventInit newOfflineAudioCompletionEventInit({ + bool bubbles, + bool cancelable, + bool composed, + required AudioBuffer renderedBuffer, + }) => OfflineAudioCompletionEventInit(bubbles: bubbles, cancelable: cancelable, composed: composed); + + AudioBuffer get renderedBuffer; + set renderedBuffer(AudioBuffer value); +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class AudioBuffer implements t.AudioBuffer { + + AudioBuffer newAudioBuffer(AudioBufferOptions options) => AudioBuffer(options); + + TauFloat32Array getChannelData(int channel); + void copyFromChannel( + TauFloat32Array destination, + int channelNumber, [ + int bufferOffset, + ]); + void copyToChannel( + TauFloat32Array source, + int channelNumber, [ + int bufferOffset, + ]); + double get sampleRate; + int get length; + double get duration; + int get numberOfChannels; +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + +class AudioBufferOptions implements t.AudioBufferOptions { + + AudioBufferOptions newAudioBufferOptions({ + int numberOfChannels, + required int length, + required num sampleRate, + }) => AudioBufferOptions(numberOfChannels: numberOfChannels, length: length, sampleRate: sampleRate); + + int get numberOfChannels; + set numberOfChannels(int value); + int get length; + set length(int value); + double get sampleRate; + set sampleRate(num value); +} + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +abstract class AudioNode implements t.AudioNode { + AudioNode? connect( + TauObject destinationNodeOrDestinationParam, [ + int output, + int input, + ]); + void disconnect([ + TauAny destinationNodeOrDestinationParamOrOutput, + int output, + int input, + ]); + BaseAudioContext get context; + int get numberOfInputs; + int get numberOfOutputs; + int get channelCount; + set channelCount(int value); + ChannelCountMode get channelCountMode; + set channelCountMode(ChannelCountMode value); + ChannelInterpretation get channelInterpretation; + set channelInterpretation(ChannelInterpretation value); +} + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + +class AudioNodeOptions implements t.AudioNodeOptions { + + AudioNodeOptions newAudioNodeOptions({ + int channelCount, + ChannelCountMode newchannelCountMode, + ChannelInterpretation channelInterpretation, + }) => AudioNodeOptions(channelCount: channelCount, channelCountMode: channelCountMode, channelInterpretation: channelInterpretation); + + int get channelCount; + set channelCount(int value); + ChannelCountMode get channelCountMode; + set channelCountMode(ChannelCountMode value); + ChannelInterpretation get channelInterpretation; + set channelInterpretation(ChannelInterpretation value); +} + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +abstract class AudioParam t.AudioParam { + AudioParam setValueAtTime( + num value, + num startTime, + ); + AudioParam linearRampToValueAtTime( + num value, + num endTime, + ); + AudioParam exponentialRampToValueAtTime( + num value, + num endTime, + ); + + AudioParam setTargetAtTime( + num target, + num startTime, + num timeConstant, + ); + AudioParam setValueCurveAtTime( + TauArray values, + num startTime, + num duration, + ); + AudioParam cancelScheduledValues(num cancelTime); + AudioParam cancelAndHoldAtTime(num cancelTime); + double get value; + set value(num value); + AutomationRate get automationRate; + set automationRate(AutomationRate value); + double get defaultValue; + double get minValue; + double get maxValue; +} + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +abstract class AudioScheduledSourceNode extends AudioNode implements t.AudioScheduledSourceNode { + void start([num when]); + void stop([num when]); + EventHandler get onended; + set onended(EventHandler value); +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class AnalyserNode extends AudioNode implements t.AnalyserNode { + + AnalyserNode newAnalyserNode( + BaseAudioContext context, [ + AnalyserOptions options, + ]) => AnalyserNode(context, options); + + void getFloatFrequencyData(TauFloat32Array array); + void getByteFrequencyData(TauUint8Array array); + void getFloatTimeDomainData(TauFloat32Array array); + void getByteTimeDomainData(TauUint8Array array); + int get fftSize; + set fftSize(int value); + int get frequencyBinCount; + double get minDecibels; + set minDecibels(num value); + double get maxDecibels; + set maxDecibels(num value); + double get smoothingTimeConstant; + set smoothingTimeConstant(num value); +} + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class AnalyserOptions extends AudioNodeOptions implements t.AnalyserOptions { + + AnalyserOptions newAnalyserOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + int fftSize, + num maxDecibels, + num minDecibels, + num smoothingTimeConstant, + }) => AnalyserOptions( + channelCount: channelCount, + channelCountMode: channelCountMode, + channelInterpretation: channelInterpretation, + fftSize: fftSize, + maxDecibels: maxDecibels, + minDecibels: minDecibels, + smoothingTimeConstant: smoothingTimeConstant, + ); + + int get fftSize; + set fftSize(int value); + double get maxDecibels; + set maxDecibels(num value); + double get minDecibels; + set minDecibels(num value); + double get smoothingTimeConstant; + set smoothingTimeConstant(num value); +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class AudioBufferSourceNode extends AudioScheduledSourceNode implements t.AudioBufferSourceNode { + + AudioBufferSourceNode newAudioBufferSourceNode( + BaseAudioContext context, [ + AudioBufferSourceOptions options, + ]) => AudioBufferSourceNode(context, options); + + void start([ + num when, + num offset, + num duration, + ]); + + AudioBuffer? get buffer; + set buffer(AudioBuffer? value); + AudioParam get playbackRate; + AudioParam get detune; + bool get loop; + set loop(bool value); + double get loopStart; + set loopStart(num value); + double get loopEnd; + set loopEnd(num value); +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class AudioBufferSourceOptions implements t.AudioBufferSourceOptions { + + AudioBufferSourceOptions newAudioBufferSourceOptions({ + AudioBuffer? buffer, + num detune, + bool loop, + num loopEnd, + num loopStart, + num playbackRate, + }) => ( + buffer: buffer, + detune: detune, + loop: loop, + loopEnd: loopEnd, + loopStart: loopStart, + playbackRate: playbackRate, + ); + + AudioBuffer? get buffer; + set buffer(AudioBuffer? value); + double get detune; + set detune(num value); + bool get loop; + set loop(bool value); + double get loopEnd; + set loopEnd(num value); + double get loopStart; + set loopStart(num value); + double get playbackRate; + set playbackRate(num value); +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + +abstract class AudioDestinationNode extends AudioNode implements t.AudioDestinationNode { + int get maxChannelCount; +} + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class AudioListener implements t.AudioListener { + void setPosition( + num x, + num y, + num z, + ); + void setOrientation( + num x, + num y, + num z, + num xUp, + num yUp, + num zUp, + ); + AudioParam get positionX; + AudioParam get positionY; + AudioParam get positionZ; + AudioParam get forwardX; + AudioParam get forwardY; + AudioParam get forwardZ; + AudioParam get upX; + AudioParam get upY; + AudioParam get upZ; +} + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + + +class AudioProcessingEvent implements t.AudioProcessingEvent { + + AudioProcessingEvent newAudioProcessingEvent( + String type, + AudioProcessingEventInit eventInitDict, + ) => AudioProcessingEvent(type, eventInitDict); + + double get playbackTime; + AudioBuffer get inputBuffer; + AudioBuffer get outputBuffer; +} + + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class AudioProcessingEventInit implements t.AudioProcessingEventInit { + + AudioProcessingEventInit newAudioProcessingEventInit({ + bool bubbles, + bool cancelable, + bool composed, + required num playbackTime, + required AudioBuffer inputBuffer, + required AudioBuffer outputBuffer, + }) => AudioProcessingEventInit( + bubbles: bubbles, + cancelable: cancelable, + composed: composed, + playbackTime: playbackTime, + inputBuffer: inputBuffer, + outputBuffer: outputBuffer, + ); + + double get playbackTime; + set playbackTime(num value); + AudioBuffer get inputBuffer; + set inputBuffer(AudioBuffer value); + AudioBuffer get outputBuffer; + set outputBuffer(AudioBuffer value); +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class BiquadFilterNode extends AudioNode implements t.BiquadFilterNode { + + BiquadFilterNode newBiquadFilterNode( + BaseAudioContext context, [ + BiquadFilterOptions options, + ]) => BiquadFilterNode( + context, options + + void getFrequencyResponse( + TauFloat32Array frequencyHz, + TauFloat32Array magResponse, + TauFloat32Array phaseResponse, + ); + BiquadFilterType get type; + set type(BiquadFilterType value); + AudioParam get frequency; + AudioParam get detune; + AudioParam get Q; + AudioParam get gain; +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + +class BiquadFilterOptions extends AudioNodeOptions implements t.BiquadFilterOptions { + +BiquadFilterOptions newBiquadFilterOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + BiquadFilterType type, + num Q, + num detune, + num frequency, + num gain, + }) => BiquadFilterOptions( + channelCount: channelCount, + channelCountMode: channelCountMode, + channelInterpretation: channelInterpretation, + type: type, + Q: Q, + detune: detune, + frequency: frequency, + gain: gain, + ); + + BiquadFilterType get type; + set type(BiquadFilterType value); + double get Q; + set Q(num value); + double get detune; + set detune(num value); + double get frequency; + set frequency(num value); + double get gain; + set gain(num value); +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class ChannelMergerNode extends AudioNodeOptions implements t.ChannelMergerNode { + + ChannelMergerNode newChannelMergerNode( + BaseAudioContext context, [ + ChannelMergerOptions options, + ]) => ChannelMergerNode( + context, + options, + ); + +} + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class ChannelMergerOptions extends AudioNodeOptions implements t.ChannelMergerOptions { + + ChannelMergerOptions newChannelMergerOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + int numberOfInputs, + }) => ChannelMergerOptions( + channelCount: channelCount, + channelCountMode: channelCountMode, + channelInterpretation: channelInterpretation, + numberOfInputs: numberOfInputs, + ); + + int get numberOfInputs; + set numberOfInputs(int value); +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class ChannelSplitterNode extends AudioNode implements t.ChannelSplitterNode { + ChannelSplitterNode newChannelSplitterNode( + BaseAudioContext context, [ + ChannelSplitterOptions options, + ]) => ChannelSplitterNode( + context, + options, + ); + + +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + + +class ChannelSplitterOptions extends AudioNodeOptions implements t.ChannelSplitterOptions { + + ChannelSplitterOptions newChannelSplitterOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + int numberOfOutputs, + }) => ChannelSplitterOptions( + channelCount: channelCount, + channelCountMode: channelCountMode, + channelInterpretation: channelInterpretation, + numberOfOutputs: numberOfOutputs, + ); + + int get numberOfOutputs; + set numberOfOutputs(int value); +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + + +class ConstantSourceNode AudioScheduledSourceNode implements t.ConstantSourceNode { + + ConstantSourceNode newConstantSourceNode( + BaseAudioContext context, [ + ConstantSourceOptions options, + ]) => ConstantSourceNode( + context, + options, + ); + + AudioParam get offset; +} + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class ConstantSourceOptions extends implements t.ConstantSourceOptions { + + ConstantSourceOption newConstantSourceOptions({num offset}) => ConstantSourceOption(offset: offset); + + double get offset; + set offset(num value); +} + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class ConvolverNode extends AudioNode implements t.ConvolverNode { + + ConvolverNode newConvolverNode( + BaseAudioContext context, [ + ConvolverOptions options, + ]) => ConstantSourceOption( + context, + options, + ); + + AudioBuffer? get buffer; + set buffer(AudioBuffer? value); + bool get normalize; + set normalize(bool value); +} + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + +class ConvolverOptions extends AudioNodeOptions implements t.ConvolverOptions { + + ConvolverOptions newConvolverOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + AudioBuffer? buffer, + bool disableNormalization, + }) => ConvolverOptions( + channelCount: channelCount, + channelCountMode: channelCountMode, + channelInterpretation: channelInterpretation, + buffer: buffer, + disableNormalization: disableNormalization, + ); + + AudioBuffer? get buffer; + set buffer(AudioBuffer? value); + bool get disableNormalization; + set disableNormalization(bool value); +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + + +class DelayNode extends AudioNode implements t.DelayNode { + + DelayNode newDelayNode( + BaseAudioContext context, [ + DelayOptions options, + ]) => DelayNode( + context, + options, + ); + + AudioParam get delayTime; +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + + +class DelayOptions extends AudioNodeOptions implements t.DelayOptions { + + DelayOptions newDelayOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + num maxDelayTime, + num delayTime, + }) => DelayOptions( + channelCount: channelCount, + channelCountMode: channelCountMode, + channelInterpretation: channelInterpretation, + maxDelayTime: maxDelayTime, + delayTime: delayTime, + ); + + double get maxDelayTime; + set maxDelayTime(num value); + double get delayTime; + set delayTime(num value); +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + +class DynamicsCompressorNode extends AudioNode implements t.DynamicsCompressorNode { + + DynamicsCompressorNode newDynamicsCompressorNode( + BaseAudioContext context, [ + DynamicsCompressorOptions options, + ]) => DynamicsCompressorNode( + context, + options, + ); + + AudioParam get threshold; + AudioParam get knee; + AudioParam get ratio; + double get reduction; + AudioParam get attack; + AudioParam get release; +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class DynamicsCompressorOptions extends AudioNodeOptions implements t.DynamicsCompressorOptions { + + DynamicsCompressorOptions newDynamicsCompressorOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + num attack, + num knee, + num ratio, + num release, + num threshold, + }) => DynamicsCompressorOptions( + channelCount: channelCount, + channelCountMode: channelCountMode, + channelInterpretation: channelInterpretation, + attack: attack, + knee: knee, + ratio: ratio, + release: release, + threshold: threshold, + ); + + double get attack; + set attack(num value); + double get knee; + set knee(num value); + double get ratio; + set ratio(num value); + double get release; + set release(num value); + double get threshold; + set threshold(num value); +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + + + +class GainNode extends AudioNode implements t.GainNode{ + + GainNode newGainNode( + BaseAudioContext context, [ + GainOptions options, + ]) => GainNode( + context, + options, + ); + + AudioParam get gain; +} + + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class GainOptions extends AudioNodeOptions implements t.GainOptions { + + GainOptions newGainOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + num gain, + }) => GainOptions( + channelCount: channelCount, + channelCountMode: channelCountMode, + channelInterpretation: channelInterpretation, + gain: gain, + ); + + double get gain; + set gain(num value); +} + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class IIRFilterNode extends AudioNode implements t.IIRFilterNode { + + IIRFilterNode newIIRFilterNode( + BaseAudioContext context, + IIRFilterOptions options, + ) => IIRFilterNode( + context, + options, + ); + + void getFrequencyResponse( + TauFloat32Array frequencyHz, + TauFloat32Array magResponse, + TauFloat32Array phaseResponse, + ); +} + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + + + +class IIRFilterOptions extends AudioNodeOptions implements t.IIRFilterNode { + + IIRFilterOptions newIIRFilterOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + required JSArray feedforward, + required JSArray feedback, + }) => IIRFilterOptions( + channelCount: channelCount, + channelCountMode: channelCountMode, + channelInterpretation: channelInterpretation, + feedforward: feedforward, + feedback: feedback + ); + + TauArray get feedforward; + set feedforward(TauArray value); + TauArray get feedback; + set feedback(TauArray value); +} + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + + + +class MediaElementAudioSourceNode extends AudioNode implements t.MediaElementAudioSourceNode { + + MediaElementAudioSourceNode newMediaElementAudioSourceNode( + AudioContext context, + MediaElementAudioSourceOptions options, + ) => MediaElementAudioSourceNode( + context, + options, + ); + + HTMLMediaElement get mediaElement; +} + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + + +class MediaElementAudioSourceOptions implements t.MediaElementAudioSourceOptions { + + MediaElementAudioSourceOptions newMediaElementAudioSourceOptions( + {required HTMLMediaElement mediaElement}) => MediaElementAudioSourceOptions( + mediaElement: mediaElement, + ); + + HTMLMediaElement get mediaElement; + set mediaElement(HTMLMediaElement value); +} + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class MediaStreamAudioDestinationNode extends AudioNode implements t.MediaStreamAudioDestinationNode { + + MediaStreamAudioDestinationNode newMediaStreamAudioDestinationNode( + AudioContext context, [ + AudioNodeOptions options, + ]) => MediaStreamAudioDestinationNode( + context, + options, + ); + + MediaStream get stream; +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + + +class MediaStreamAudioSourceNode extends AudioNode implements t.MediaStreamAudioSourceNode { + + MediaStreamAudioSourceNode newMediaStreamAudioSourceNode( + AudioContext context, + MediaStreamAudioSourceOptions options, + ) => MediaStreamAudioSourceNode( + context, + options, + ); + + MediaStream get mediaStream; +} + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class MediaStreamAudioSourceOptions implements t.MediaStreamAudioSourceOptions { + + MediaStreamAudioSourceOptions newMediaStreamAudioSourceOptions( + {required MediaStream mediaStream}) => MediaStreamAudioSourceOptions( + mediaStream: mediaStream, + ); + + MediaStream get mediaStream; + set mediaStream(MediaStream value); +} + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class MediaStreamTrackAudioSourceNode extends AudioNode implements t.MediaStreamTrackAudioSourceNode { + + MediaStreamTrackAudioSourceNode newMediaStreamTrackAudioSourceNode( + AudioContext context, + MediaStreamTrackAudioSourceOptions options, + ) => MediaStreamTrackAudioSourceNode( + context, + options, + ); + +} + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class MediaStreamTrackAudioSourceOptions implements t.MediaStreamTrackAudioSourceNode { + + MediaStreamTrackAudioSourceOptions newMediaStreamTrackAudioSourceOptions( + {required MediaStreamTrack mediaStreamTrack}) => MediaStreamTrackAudioSourceOptions( + mediaStreamTrack: mediaStreamTrack, + ); + + MediaStreamTrack get mediaStreamTrack; + set mediaStreamTrack(MediaStreamTrack value); +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + + +class OscillatorNode extends AudioScheduledSourceNode implements t.OscillatorNode { + + OscillatorNode newOscillatorNode( + BaseAudioContext context, [ + OscillatorOptions options, + ]) => OscillatorNode( + context, + options, + ); + + void setPeriodicWave(PeriodicWave periodicWave); + OscillatorType get type; + set type(OscillatorType value); + AudioParam get frequency; + AudioParam get detune; +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + + + + + +class OscillatorOptions extends AudioNodeOptions implements t.OscillatorOptions { + + OscillatorOptions newOscillatorOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + OscillatorType type, + num frequency, + num detune, + PeriodicWave periodicWave, + }) => OscillatorOptions( + channelCount: channelCount, + channelCountMode: channelCountMode, + channelInterpretation: channelInterpretation, + type: type, + frequency: frequency, + detune: detune, + periodicWave: periodicWave, + ); + + OscillatorType get type; + set type(OscillatorType value); + double get frequency; + set frequency(num value); + double get detune; + set detune(num value); + PeriodicWave get periodicWave; + set periodicWave(PeriodicWave value); +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + + + +class PannerNode extends AudioNode implements t.PannerNode { + + PannerNode newPannerNode( + BaseAudioContext context, [ + PannerOptions options, + ]) => PannerNode( + context, + options, + ); + + void setPosition( + num x, + num y, + num z, + ); + + void setOrientation( + num x, + num y, + num z, + ); + PanningModelType get panningModel; + set panningModel(PanningModelType value); + AudioParam get positionX; + AudioParam get positionY; + AudioParam get positionZ; + AudioParam get orientationX; + AudioParam get orientationY; + AudioParam get orientationZ; + DistanceModelType get distanceModel; + set distanceModel(DistanceModelType value); + double get refDistance; + set refDistance(num value); + double get maxDistance; + set maxDistance(num value); + double get rolloffFactor; + set rolloffFactor(num value); + double get coneInnerAngle; + set coneInnerAngle(num value); + double get coneOuterAngle; + set coneOuterAngle(num value); + double get coneOuterGain; + set coneOuterGain(num value); +} + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + + + +class PannerOptions extends AudioNodeOptions implements t.PannerOptions { + + PannerOptions newPannerOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + PanningModelType panningModel, + DistanceModelType distanceModel, + num positionX, + num positionY, + num positionZ, + num orientationX, + num orientationY, + num orientationZ, + num refDistance, + num maxDistance, + num rolloffFactor, + num coneInnerAngle, + num coneOuterAngle, + num coneOuterGain, + }) => newPannerOptions( + channelCount: channelCount, + channelCountMode: channelCountMode, + channelInterpretation: channelInterpretation, + panningModel: panningModel, + distanceModel: distanceModel, + positionX: positionX, + positionY: positionY, + positionZ: positionZ, + orientationX: orientationX, + orientationY: orientationY, + orientationZ: orientationZ, + refDistance: refDistance, + maxDistance: maxDistance, + rolloffFactor: rolloffFactor, + coneInnerAngle: coneInnerAngle, + coneOuterAngle: coneOuterAngle, + coneOuterGain: coneOuterGain, + ); + + PanningModelType get panningModel; + set panningModel(PanningModelType value); + DistanceModelType get distanceModel; + set distanceModel(DistanceModelType value); + double get positionX; + set positionX(num value); + double get positionY; + set positionY(num value); + double get positionZ; + set positionZ(num value); + double get orientationX; + set orientationX(num value); + double get orientationY; + set orientationY(num value); + double get orientationZ; + set orientationZ(num value); + double get refDistance; + set refDistance(num value); + double get maxDistance; + set maxDistance(num value); + double get rolloffFactor; + set rolloffFactor(num value); + double get coneInnerAngle; + set coneInnerAngle(num value); + double get coneOuterAngle; + set coneOuterAngle(num value); + double get coneOuterGain; + set coneOuterGain(num value); +} + + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + + +class PeriodicWave implements t.PeriodicWave { + + PeriodicWave newPeriodicWave( + BaseAudioContext context, [ + PeriodicWaveOptions options, + ]) => PeriodicWave( + context, + options, + ); + +} + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + + + +class PeriodicWaveConstraints t.PeriodicWaveConstraints { + + PeriodicWaveConstraints newPeriodicWaveConstraints({bool disableNormalization}) => PeriodicWaveConstraints(disableNormalization: disableNormalization); + + bool get disableNormalization; + set disableNormalization(bool value); +} + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + + +class PeriodicWaveOptions extends PeriodicWaveConstraints implements t.PeriodicWaveOptions { + + PeriodicWaveOptions newPeriodicWaveOptions({ + bool disableNormalization, + JSArray real, + JSArray imag, + }) => PeriodicWaveConstraints( + disableNormalization: disableNormalization, + real: real, + imag: imag, + ); + + TauArray get real; + set real(TauArray value); + TauArray get imag; + set imag(TauArray value); +} + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class ScriptProcessorNode extends AudioNode implements t.ScriptProcessorNode { + EventHandler get onaudioprocess; + set onaudioprocess(EventHandler value); + int get bufferSize; +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + + +class StereoPannerNode extends AudioNode implements t.StereoPannerNode { + + StereoPannerNode newStereoPannerNode( + BaseAudioContext context, [ + StereoPannerOptions options, + ]) => StereoPannerNode( + context, + options, + ); + + AudioParam get pan; +} + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + + +class StereoPannerOptions extends AudioNodeOptions implements t.StereoPannerOptions { + + StereoPannerOptions newStereoPannerOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + num pan, + }) => StereoPannerOptions( + channelCount: channelCount, + channelCountMode: channelCountMode, + channelInterpretation: channelInterpretation, + pan: pan, + ); + + double get pan; + set pan(num value); +} + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class WaveShaperNode extends AudioNode implements t.WaveShaperNode { + + WaveShaperNode newWaveShaperNode( + BaseAudioContext context, [ + WaveShaperOptions options, + ]) => WaveShaperNode( + context, + options, + ); + + TauFloat32Array? get curve; + set curve(TauFloat32Array? value); + OverSampleType get oversample; + set oversample(OverSampleType value); +} + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + + +class WaveShaperOptions extends AudioNodeOptions implements t.WaveShaperOptions { + + WaveShaperOptions newWaveShaperOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + JSArray curve, + OverSampleType oversample, + }) => WaveShaperOptions( + channelCount: channelCount, + channelCountMode: channelCountMode, + channelInterpretation: channelInterpretation, + curve: curve, + oversample: oversample, + ); + + TauArray get curve; + set curve(TauArray value); + OverSampleType get oversample; + set oversample(OverSampleType value); +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class AudioWorklet implements t.AudioWorklet { + +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class AudioWorkletGlobalScope extends WorkletGlobalScope implements t.AudioWorkletGlobalScope { + void registerProcessor( + String name, + AudioWorkletProcessorConstructor processorCtor, + ); + int get currentFrame; + double get currentTime; + double get sampleRate; +} + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + + + +class AudioParamMap implements t.AudioParamMap {} + + + + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + + +class AudioWorkletNode extends AudioNode implements t.AudioWorkletNode { + + AudioWorkletNode newAudioWorkletNode( + BaseAudioContext context, + String name, [ + AudioWorkletNodeOptions options, + ]) => AudioWorkletNode( + context, + name, + options, + ); + + + AudioParamMap get parameters; + MessagePort get port; + EventHandler get onprocessorerror; + set onprocessorerror(EventHandler value); +} + + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + + + + +class AudioWorkletNodeOptions extends AudioNodeOptions implements t.AudioWorkletNodeOptions { + + AudioWorkletNodeOptions newAudioWorkletNodeOptions({ + int channelCount, + ChannelCountMode channelCountMode, + ChannelInterpretation channelInterpretation, + int numberOfInputs, + int numberOfOutputs, + JSArray outputChannelCount, + JSObject parameterData, + JSObject processorOptions, + }) => AudioWorkletNodeOptions( + channelCount: channelCount, + channelCountMode: channelCountMode, + channelInterpretation: channelInterpretation, + numberOfInputs: numberOfInputs, + numberOfOutputs: numberOfOutputs, + outputChannelCount: outputChannelCount, + parameterData: parameterData, + processorOptions: processorOptions, + ); + + int get numberOfInputs; + set numberOfInputs(int value); + int get numberOfOutputs; + set numberOfOutputs(int value); + TauArray get outputChannelCount; + set outputChannelCount(TauArray value); + TauObject get parameterData; + set parameterData(TauObject value); + TauObject get processorOptions; + set processorOptions(TauObject value); +} + + + + + + +// ------------------------------------------------------------------------------------------------------------------ + + + + + +class AudioWorkletProcessor implements t.AudioWorkletProcessor { + MessagePort get port; +} + + + + +// ------------------------------------------------------------------------------------------------------------------ + diff --git a/lib/tauwaweb.dart b/lib/tauwaweb.dart new file mode 100644 index 0000000..99f46e6 --- /dev/null +++ b/lib/tauwaweb.dart @@ -0,0 +1,4 @@ +library tauwaweb; + +export 'src/tauwaweb_audio.dart'; +export 'src/tauwaweb_implementation.dart'; \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 0000000..5a1e998 --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,57 @@ +name: tauwaweb +description: "A Tauwa implementation for the Web." +version: 0.0.1 +homepage: + +environment: + sdk: ^3.5.3 + flutter: ">=1.17.0" + +dependencies: + flutter: + sdk: flutter + tauwa: # ^9.15.61 + path: ../tauwa # tauwa Dir + web: ^1.0.0 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^4.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + # To add assets to your package, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + # + # For details regarding assets in packages, see + # https://flutter.dev/to/asset-from-package + # + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/to/resolution-aware-images + + # To add custom fonts to your package, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts in packages, see + # https://flutter.dev/to/font-from-package diff --git a/test/tauwaweb_test.dart b/test/tauwaweb_test.dart new file mode 100644 index 0000000..564dda1 --- /dev/null +++ b/test/tauwaweb_test.dart @@ -0,0 +1,12 @@ +import 'package:flutter_test/flutter_test.dart'; + +import 'package:tauwaweb/tauwaweb.dart'; + +void main() { + test('adds one to input values', () { + final calculator = Calculator(); + expect(calculator.addOne(2), 3); + expect(calculator.addOne(-7), -6); + expect(calculator.addOne(0), 1); + }); +}