Skip to content

Commit

Permalink
taudio-waa_native
Browse files Browse the repository at this point in the history
  • Loading branch information
Larpoux committed Mar 10, 2022
1 parent fbdb0ea commit 5c0995a
Show file tree
Hide file tree
Showing 45 changed files with 664 additions and 2,522 deletions.
2 changes: 0 additions & 2 deletions .bundle/config

This file was deleted.

10 changes: 0 additions & 10 deletions .metadata

This file was deleted.

5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
## 0.0.2-beta-1+3

- ## The [CHANGELOG file is here](https://tau.canardoux.xyz/doc-v9/changelog.html)
## 0.0.1

* TODO: Describe initial release.
374 changes: 1 addition & 373 deletions LICENSE

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
# taudio-waa
# taudio_waa

A new Flutter plugin project.

## Getting Started

This project is a starting point for a Flutter
[plug-in package](https://flutter.dev/developing-packages/),
a specialized package that includes platform-specific implementation code for
Android and/or iOS.

For help getting started with Flutter development, view the
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.

4 changes: 0 additions & 4 deletions analysis_options.yaml

This file was deleted.

33 changes: 3 additions & 30 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// The Android Gradle Plugin builds the native code with the Android NDK.

group 'xyz.canardoux.taudio_waa'
group 'xyz.thetatau.taudio_waa'
version '1.0'

buildscript {
Expand All @@ -10,7 +8,6 @@ buildscript {
}

dependencies {
// The Android Gradle Plugin knows how to build native code with the NDK.
classpath 'com.android.tools.build:gradle:4.1.0'
}
}
Expand All @@ -25,38 +22,14 @@ rootProject.allprojects {
apply plugin: 'com.android.library'

android {
// Bumping the plugin compileSdkVersion requires all clients of this plugin
// to bump the version in their app.
compileSdkVersion 32
defaultConfig {
minSdkVersion 24
}

// Bumping the plugin ndkVersion requires all clients of this plugin to bump
// the version in their app and to download a newer version of the NDK.
ndkVersion "21.1.6352462"

// Invoke the shared CMake build with the Android Gradle Plugin.
externalNativeBuild {
cmake {
path "../src/CMakeLists.txt"

// The default CMake version for the Android Gradle Plugin is 3.10.2.
// https://developer.android.com/studio/projects/install-ndk#vanilla_cmake
//
// The Flutter tooling requires that developers have CMake 3.10 or later
// installed. You should not increase this version, as doing so will cause
// the plugin to fail to compile for some customers of the plugin.
// version "3.10.2"
}
}
compileSdkVersion 31

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
minSdkVersion 24
minSdkVersion 16
}
}
2 changes: 1 addition & 1 deletion android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="xyz.canardoux.taudio_waa">
package="xyz.thetatau.taudio_waa">
</manifest>
38 changes: 38 additions & 0 deletions android/src/main/java/xyz/thetatau/taudio_waa/TaudioWaaPlugin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package xyz.thetatau.taudio_waa;

import androidx.annotation.NonNull;

import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;

/** TaudioWaaPlugin */
public class TaudioWaaPlugin implements FlutterPlugin, MethodCallHandler {
/// The MethodChannel that will the communication between Flutter and native Android
///
/// This local reference serves to register the plugin with the Flutter Engine and unregister it
/// when the Flutter Engine is detached from the Activity
private MethodChannel channel;

@Override
public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) {
channel = new MethodChannel(flutterPluginBinding.getBinaryMessenger(), "taudio_waa");
channel.setMethodCallHandler(this);
}

@Override
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
if (call.method.equals("getPlatformVersion")) {
result.success("Android " + android.os.Build.VERSION.RELEASE);
} else {
result.notImplemented();
}
}

@Override
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
channel.setMethodCallHandler(null);
}
}
36 changes: 36 additions & 0 deletions bin/pub.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

git add .
VERSION=$1

if [ -z "$VERSION" ]; then
echo "Correct syntax is $0 <VERSION>"
exit -1
fi


dart analyze lib
if [ $? -ne 0 ]; then
echo "Error"
exit -1
fi
dart format lib
if [ $? -ne 0 ]; then
echo "Error"
exit -1
fi

dart analyze example/lib
if [ $? -ne 0 ]; then
echo "Error"
exit -1
fi
dart format example/lib
if [ $? -ne 0 ]; then
echo "Error"
exit -1
fi



flutter pub publish
7 changes: 7 additions & 0 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,10 @@ post_install do |installer|
flutter_additional_ios_build_settings(target)
end
end


# =====================================================
# The following instruction is only for Tau debugging.
# Do not insert such a line in a real App.
pod 'taudio_waa_native', :path => '../../../taudio-waa_native'
# =====================================================
9 changes: 7 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,26 @@ PODS:
- Flutter (1.0.0)
- taudio_waa (0.0.1):
- Flutter
- taudio_waa_native (9.0.0-beta-1)

DEPENDENCIES:
- Flutter (from `Flutter`)
- taudio_waa (from `.symlinks/plugins/taudio_waa/ios`)
- taudio_waa_native (from `../../../taudio-waa_native`)

EXTERNAL SOURCES:
Flutter:
:path: Flutter
taudio_waa:
:path: ".symlinks/plugins/taudio_waa/ios"
taudio_waa_native:
:path: "../../../taudio-waa_native"

SPEC CHECKSUMS:
Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
taudio_waa: c8c9ed3b96fcb34470b7fe0065c10d1e3f18e4b2
taudio_waa: 22320709467a9d19a6c787370a5b43bbf34386f4
taudio_waa_native: df8c464a8efeb437841e4fa53c6fabde47f2a1aa

PODFILE CHECKSUM: b0b272159268c64df66b1b276887e0e0629a3acb
PODFILE CHECKSUM: 5be4f87c29fca89639722ecc6418a8f682d20425

COCOAPODS: 1.11.2
77 changes: 60 additions & 17 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'dart:async';

import 'package:taudio_waa/taudio_waa.dart' as taudio_waa;
import 'package:taudio_waa/taudio_waa.dart' ;

void main() {
runApp(const MyApp());
Expand All @@ -14,17 +13,72 @@ class MyApp extends StatefulWidget {
_MyAppState createState() => _MyAppState();
}


class _MyAppState extends State<MyApp> {
late int sumResult;
late Future<int> sumAsyncResult;

@override
void initState() {
super.initState();
sumResult = taudio_waa.sum(1, 2);
sumAsyncResult = taudio_waa.sumAsync(3, 4);
sumResult = TaudioWaa().sum(1, 2);
}



void onPressed()
{

String s = TaudioWaa().greeting("John Smith");
print(s);
/*
// Prepare the parameters
final nameStr = "John Smith";
final Pointer<Utf8> namePtr = nameStr.toNativeUtf8(); //Utf8.toUtf8(nameStr);
print("- Calling rust_greeting with argument: $namePtr");
// Call rust_greeting
final Pointer<Utf8> resultPtr = rustGreeting(namePtr);
print("- Result pointer: $resultPtr");
// Handle the result pointer
final String greetingStr = resultPtr.toDartString();
print("- Response string: $greetingStr");
*/
/*
// Create an empty two second stereo buffer at the
// sample rate of the AudioContext
var frameCount = (audioCtx.sampleRate! * 2). floor();
var myArrayBuffer = audioCtx.createBuffer(channels, frameCount, audioCtx.sampleRate!);
// Fill the buffer with white noise;
//just random values between -1.0 and 1.0
for (int channel = 0; channel < channels; channel++) {
// This gives us the actual array that contains the data
var nowBuffering = myArrayBuffer.getChannelData(channel);
for (int i = 0; i < frameCount; i++) {
// rng.nextInt(2) is in [0; 2]
// audio needs to be in [-1.0; 1.0]
nowBuffering[i] = rng.nextInt(2) - 1;
}
}
// Get an AudioBufferSourceNode.
// This is the AudioNode to use when we want to play an AudioBuffer
var source = audioCtx.createBufferSource();
// set the buffer in the AudioBufferSourceNode
source.buffer = myArrayBuffer;
// connect the AudioBufferSourceNode to the
// destination so we can hear the sound
source.connectNode(audioCtx.destination!);
// start the source playing
source.start();
*/
}


@override
Widget build(BuildContext context) {
const textStyle = TextStyle(fontSize: 25);
Expand Down Expand Up @@ -52,18 +106,7 @@ class _MyAppState extends State<MyApp> {
textAlign: TextAlign.center,
),
spacerSmall,
FutureBuilder<int>(
future: sumAsyncResult,
builder: (BuildContext context, AsyncSnapshot<int> value) {
final displayValue =
(value.hasData) ? value.data : 'loading';
return Text(
'await sumAsync(3, 4) = $displayValue',
style: textStyle,
textAlign: TextAlign.center,
);
},
),
RaisedButton(onPressed: onPressed, child: Text('Make white noise')),
],
),
),
Expand Down
4 changes: 4 additions & 0 deletions example/linux/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

#include "generated_plugin_registrant.h"

#include <taudio_waa/taudio_waa_plugin.h>

void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) taudio_waa_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "TaudioWaaPlugin");
taudio_waa_plugin_register_with_registrar(taudio_waa_registrar);
}
2 changes: 1 addition & 1 deletion example/linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#

list(APPEND FLUTTER_PLUGIN_LIST
taudio_waa
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
taudio_waa
)

set(PLUGIN_BUNDLED_LIBRARIES)
Expand Down
2 changes: 2 additions & 0 deletions example/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import FlutterMacOS
import Foundation

import taudio_waa

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
TaudioWaaPlugin.register(with: registry.registrar(forPlugin: "TaudioWaaPlugin"))
}
Loading

0 comments on commit 5c0995a

Please sign in to comment.