Skip to content

Commit

Permalink
Merge pull request #40 from designe/v0.8
Browse files Browse the repository at this point in the history
master branch with v0.8
  • Loading branch information
designe authored Sep 13, 2021
2 parents 9a72b75 + 5e89ae6 commit 5496692
Show file tree
Hide file tree
Showing 171 changed files with 5,765 additions and 3,333 deletions.
16 changes: 10 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.41'
repositories {
mavenCentral()
google()
maven {
url "https://plugins.gradle.org/m2/"
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'io.github.gradle-nexus:publish-plugin:1.1.0'
if(gradle.language.equals("kotlin")) classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.android.tools.build:gradle:4.2.2'

// for mavenCentral publish
//classpath 'io.github.gradle-nexus:publish-plugin:1.1.0'
}
}

/*
* mavenCentral publish script
*
apply plugin: 'io.github.gradle-nexus.publish-plugin'
apply from: file("publish-root.gradle")
*/

allprojects {
repositories {
mavenCentral()
google()
maven {
url "https://plugins.gradle.org/m2/"
}
google()
}
}
57 changes: 27 additions & 30 deletions euphony/build.gradle
Original file line number Diff line number Diff line change
@@ -1,41 +1,21 @@
apply plugin: 'com.android.library'
if(gradle.language.equals("kotlin")) {
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
}

apply from: file('publish.gradle')

android {
compileSdkVersion(30)
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
if(gradle.language.equals("kotlin")) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

android {
defaultConfig {
minSdkVersion 14
minSdkVersion 16
targetSdkVersion 30

ndk {
moduleName "kissff"
}

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

sourceSets {
main {
java.srcDirs = ['src/main/' + gradle.language]
}
test {
java.srcDirs = ['src/test/' + gradle.language]
/* This externalNativeBuild block is different from the one which is on the outside of defaultConfig */
externalNativeBuild {
cmake {
cppFlags "-std=c++14 -fopenmp"
arguments "-DANDROID_STL=c++_shared"
arguments "-DANDROID_SDK_ROOT=${android.getSdkDirectory().getAbsolutePath()}"
}
}
}

Expand All @@ -49,13 +29,30 @@ android {
testCoverageEnabled false
}
}

externalNativeBuild {
ndkBuild {
path file('src/main/jni/Android.mk')
cmake {
path "src/main/cpp/CMakeLists.txt"
version "3.10.2"
}
}

lintOptions {
warning 'MissingPermission'
}

buildFeatures {
prefab true
}

testOptions {
unitTests.returnDefaultValues = true
}
}

dependencies {
implementation 'com.google.oboe:oboe:1.6.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
98 changes: 98 additions & 0 deletions euphony/src/androidTest/java/co/euphony/tx/EuTxManagerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package co.euphony.tx;

import androidx.test.core.app.ApplicationProvider;
import androidx.test.filters.SmallTest;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.util.Arrays;

import co.euphony.util.EuOption;

import static org.junit.Assert.*;

@RunWith(Parameterized.class)
@SmallTest
public class EuTxManagerTest {
private static final String TX_TAG = "EU_TXMANAGER_TAG";

String code;
String expectedASCIICode;
String expectedGenCode;
int expectedStreamLength;
int expectedBufferLength;

EuTxManager txManager = null;
public EuTxManagerTest(String code, String asciiCode, String expectedGenCode, int expectedStreamLength, int expectedBufferLength) {
this.code = code;
this.expectedASCIICode = asciiCode;
this.expectedGenCode = expectedGenCode;
this.expectedStreamLength = expectedStreamLength;
this.expectedBufferLength = expectedBufferLength;
}

@Before
public void setup() {
txManager = new EuTxManager(ApplicationProvider.getApplicationContext());
}

@Test
public void getCode() {
txManager.setCode(code);

String activeResult = txManager.getCode();
assertEquals(expectedASCIICode, activeResult);
}

@Test
public void getGenCode() {
txManager.setCode(code);

String activeResult = txManager.getGenCode();
assertEquals(expectedGenCode, activeResult);
}

@Test
public void setGetCodeTest() {
txManager.setCode("a");
String activeResult = txManager.getGenCode();
assertEquals("S6197", activeResult);

txManager.setCode("b");
activeResult = txManager.getGenCode();
assertEquals("S6284", activeResult);

}

@Test
public void getGenWaveSource() {
txManager.setCode(code);
txManager.setMode(EuOption.ModeType.DEFAULT);
float[] waveSourceData = txManager.getOutStream();
assertEquals(waveSourceData.length, expectedStreamLength);
}

@Test
public void testRun() {
txManager.callEuPI(18000, EuTxManager.EuPIDuration.LENGTH_SHORT);
}

@Parameterized.Parameters
public static Iterable<Object[]> data() {
return Arrays.asList(new Object[][]{
{"a", "61", "S6197", 5*2048, 5*8},
{"b", "62", "S6284", 5*2048, 5*8},
{"c", "63", "S6375", 5*2048, 5*8},
{"abc", "616263", "S61626386", 9*2048, 9*8},
{"Abc", "416263", "S416263a4", 9*2048, 9*8},
{"lmno", "6c6d6e6f", "S6c6d6e6f20", 11*2048, 11*8},
{"efg", "656667", "S656667c2", 9*2048, 9*8},
{"abcdefghijklmnopqrstuvwxyz", "6162636465666768696a6b6c6d6e6f707172737475767778797a", "S6162636465666768696a6b6c6d6e6f707172737475767778797aaa", 55*2048, 55*8},
{"ABC", "414243", "S414243e4", 9*2048, 9*8},
{"ABCDEFGHIJKLMNOPQRSTUVWXYZ", "4142434445464748494a4b4c4d4e4f505152535455565758595a", "S4142434445464748494a4b4c4d4e4f505152535455565758595aea", 55*2048, 55*8},
});
}
}
4 changes: 1 addition & 3 deletions euphony/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="euphony.lib"
package="co.euphony"
android:versionCode="1"
android:versionName="1.0" >

<application />

</manifest>
73 changes: 73 additions & 0 deletions euphony/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
cmake_minimum_required(VERSION 3.4.1)

project(euphony
VERSION 0.8)

# Legacy JNI
set(LEGACY_SRC
arms/kiss_fft.c
arms/kiss_fftr.c
native-legacy.cpp
)

find_library( log-lib log )
add_library( native-legacy SHARED ${LEGACY_SRC} )
target_compile_definitions(native-legacy PUBLIC FIXED_POINT=16)
target_link_libraries(
native-legacy
${log-lib}
-fopenmp
-static-openmp
)

# Rearchitectured Euphony Native
set(EUPHONY_SRC
arms/kiss_fft.c
arms/kiss_fftr.c
core/source/AudioStreamCallback.cpp
core/source/ASCIICharset.cpp
core/source/Base2.cpp
core/source/Base16.cpp
core/source/Base16Exception.cpp
core/source/DefaultCharset.cpp
core/source/EuPIOscillator.cpp
core/source/EuPIRenderer.cpp
core/source/FFTModel.cpp
core/source/FFTProcessor.cpp
core/source/FSK.cpp
core/source/HexVector.cpp
core/source/Packet.cpp
core/source/PacketBuilder.cpp
core/source/PacketErrorDetector.cpp
core/source/TxEngine.cpp
core/source/Wave.cpp
core/source/WaveBuilder.cpp
core/source/WaveRenderer.cpp
native-connector.cpp
)

set(EUPHONY_HDR core)
set(DEBUG_HELPER debug-helper)
set(DEBUG_HELPER_SRC debug-helper/Trace.cpp)
set(SL_HEADERS arms/sl-headers)

include_directories( ${EUPHONY_HDR} ${SL_HEADERS} ${DEBUG_HELPER})

add_library(euphony SHARED ${EUPHONY_SRC} ${DEBUG_HELPER_SRC})
target_compile_definitions(euphony PUBLIC FIXED_POINT=16)

find_package(
oboe REQUIRED CONFIG
)

target_link_libraries(
euphony
${log-lib}
OpenSLES
oboe::oboe
-fopenmp
-static-openmp
)

# for c++ unit-test (gtest)
add_subdirectory(tests)
File renamed without changes.
Loading

0 comments on commit 5496692

Please sign in to comment.