├── .gitignore
├── LICENSE.md
├── README.md
├── build.gradle
├── examples
├── .gitignore
├── README.md
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── ai
│ │ └── olami
│ │ └── android
│ │ └── example
│ │ ├── Config.java
│ │ ├── MainActivity.java
│ │ ├── SpeechInputActivity.java
│ │ ├── TextInputNLIAnalysisActivity.java
│ │ └── TextInputWordSegmentationActivity.java
│ └── res
│ ├── layout
│ ├── activity_main.xml
│ ├── activity_speech_input.xml
│ ├── activity_text_input_nli_analysis.xml
│ ├── activity_text_input_word_segmentation.xml
│ └── configuration_setting.xml
│ ├── menu
│ └── menu.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_round.png
│ └── microphone.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── values-en
│ └── strings.xml
│ ├── values-zh-rTW
│ └── strings.xml
│ └── values
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── lib
├── .gitignore
├── CMakeLists.txt
├── build.gradle
├── libs
│ └── olami-java-client-1.5.1.jar
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── cpp
│ ├── native-lib.cpp
│ └── speex
│ │ ├── CMakeLists.txt
│ │ ├── include
│ │ └── speex
│ │ │ ├── speex.h
│ │ │ ├── speex_bits.h
│ │ │ ├── speex_callbacks.h
│ │ │ ├── speex_config_types.h
│ │ │ ├── speex_config_types.h.bak
│ │ │ ├── speex_header.h
│ │ │ ├── speex_stereo.h
│ │ │ └── speex_types.h
│ │ ├── libspeex
│ │ ├── _kiss_fft_guts.h
│ │ ├── arch.h
│ │ ├── bfin.h
│ │ ├── bits.c
│ │ ├── cb_search.c
│ │ ├── cb_search.h
│ │ ├── cb_search_arm4.h
│ │ ├── cb_search_bfin.h
│ │ ├── cb_search_sse.h
│ │ ├── exc_10_16_table.c
│ │ ├── exc_10_32_table.c
│ │ ├── exc_20_32_table.c
│ │ ├── exc_5_256_table.c
│ │ ├── exc_5_64_table.c
│ │ ├── exc_8_128_table.c
│ │ ├── fftwrap.h
│ │ ├── filters.c
│ │ ├── filters.h
│ │ ├── filters_arm4.h
│ │ ├── filters_bfin.h
│ │ ├── filters_sse.h
│ │ ├── fixed_arm4.h
│ │ ├── fixed_arm5e.h
│ │ ├── fixed_bfin.h
│ │ ├── fixed_debug.h
│ │ ├── fixed_generic.h
│ │ ├── gain_table.c
│ │ ├── gain_table_lbr.c
│ │ ├── hexc_10_32_table.c
│ │ ├── hexc_table.c
│ │ ├── high_lsp_tables.c
│ │ ├── kiss_fft.c
│ │ ├── kiss_fft.h
│ │ ├── kiss_fftr.c
│ │ ├── kiss_fftr.h
│ │ ├── lpc.c
│ │ ├── lpc.h
│ │ ├── lpc_bfin.h
│ │ ├── lsp.c
│ │ ├── lsp.h
│ │ ├── lsp_bfin.h
│ │ ├── lsp_tables_nb.c
│ │ ├── ltp.c
│ │ ├── ltp.h
│ │ ├── ltp_arm4.h
│ │ ├── ltp_bfin.h
│ │ ├── ltp_sse.h
│ │ ├── math_approx.h
│ │ ├── misc_bfin.h
│ │ ├── modes.c
│ │ ├── modes.h
│ │ ├── modes_wb.c
│ │ ├── nb_celp.c
│ │ ├── nb_celp.h
│ │ ├── os_support.h
│ │ ├── quant_lsp.c
│ │ ├── quant_lsp.h
│ │ ├── quant_lsp_bfin.h
│ │ ├── sb_celp.c
│ │ ├── sb_celp.h
│ │ ├── smallft.c
│ │ ├── smallft.h
│ │ ├── speex.c
│ │ ├── speex_callbacks.c
│ │ ├── speex_header.c
│ │ ├── stack_alloc.h
│ │ ├── stereo.c
│ │ ├── testenc.c
│ │ ├── testenc_uwb.c
│ │ ├── testenc_wb.c
│ │ ├── vbr.c
│ │ ├── vbr.h
│ │ ├── vorbis_psy.c
│ │ ├── vorbis_psy.h
│ │ ├── vq.c
│ │ ├── vq.h
│ │ ├── vq_arm4.h
│ │ ├── vq_bfin.h
│ │ ├── vq_sse.h
│ │ └── window.c
│ │ └── speex_jni.cpp
│ └── java
│ └── ai
│ └── olami
│ └── android
│ ├── AudioRecordManager.java
│ ├── IKeepRecordingSpeechRecognizerListener.java
│ ├── IRecorderSpeechRecognizerListener.java
│ ├── KeepRecordingSpeechRecognizer.java
│ ├── RecorderSpeechRecognizer.java
│ ├── SpeechRecognizerBase.java
│ ├── VoiceVolume.java
│ └── jni
│ └── Codec.java
├── olami-apk-test-key
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 |
15 | # Gradle files
16 | .gradle/
17 | .idea/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio
30 | .classpath
31 | .project
32 | .settings/
33 | *.iml
34 |
35 | # Android Studio Navigation editor temp files
36 | .navigation/
37 | .externalNativeBuild/
38 |
39 | # Android Studio captures folder
40 | captures/
41 |
42 | # Mac
43 | .DS_Store
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # OLAMI Android Client SDK
2 |
3 | This is a repository that contains Android SDK and code examples for using OLAMI HTTP APIs, an offering within **OLAMI Open AI**.
4 |
5 | OLAMI website and documentation: [http://olami.ai](http://olami.ai)
6 |
7 | - [简体中文在线说明文档](http://cn.olami.ai/wiki/?mp=sdk&content=sdk/android/reference.html)
8 |
9 | - [繁體中文線上說明文件](http://tw.olami.ai/wiki/?mp=sdk&content=sdk/android/reference.html)
10 |
11 | * * *
12 |
13 | ### OLAMI NLP modeling (OSL design) examples
14 |
15 | See Repository : [olami-osl-examples](https://github.com/olami-developers/olami-osl-examples)
16 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | mavenCentral()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:2.3.3'
10 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
11 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | mavenCentral()
19 | }
20 | }
21 |
22 | task clean(type: Delete) {
23 | delete rootProject.buildDir
24 | delete 'bin'
25 | }
26 |
--------------------------------------------------------------------------------
/examples/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/examples/README.md:
--------------------------------------------------------------------------------
1 | # OLAMI Android Client SDK
2 |
3 | This is a repository that contains Android SDK and code examples for using OLAMI HTTP APIs, an offering within **OLAMI Open AI**.
4 |
5 | OLAMI website and documentation: [http://olami.ai](http://olami.ai)
6 |
7 | - [简体中文在线说明文档](http://cn.olami.ai/wiki/?mp=sdk&content=sdk/android/examples/reference.html)
8 |
9 | - [繁體中文線上說明文件](http://tw.olami.ai/wiki/?mp=sdk&content=sdk/android/examples/reference.html)
10 |
--------------------------------------------------------------------------------
/examples/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.3"
6 |
7 | defaultConfig {
8 | applicationId "ai.olami.android.sample"
9 | minSdkVersion 17
10 | targetSdkVersion 25
11 | versionCode 1
12 | versionName "20190612"
13 |
14 | archivesBaseName = "olami-android-client-examples"
15 |
16 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
17 | }
18 |
19 | signingConfigs {
20 | sign {
21 | storeFile file('../olami-apk-test-key')
22 | storePassword 'http://olami.ai'
23 | keyAlias 'olami-apk-test-key'
24 | keyPassword 'olami.ai'
25 | }
26 | }
27 |
28 | buildTypes {
29 | release {
30 | minifyEnabled false
31 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
32 | signingConfig signingConfigs.sign
33 | }
34 | }
35 |
36 | lintOptions {
37 | abortOnError false
38 | }
39 |
40 | applicationVariants.all { variant ->
41 | variant.outputs.each { output ->
42 | def outputFile = output.outputFile
43 | if (outputFile != null && outputFile.name.endsWith('.apk')) {
44 | def fileName = "${archivesBaseName}.apk"
45 | output.outputFile = new File(outputFile.parent, fileName)
46 | }
47 | }
48 | }
49 | }
50 |
51 | dependencies {
52 | compile fileTree(dir: 'libs', include: ['*.jar'])
53 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
54 | exclude group: 'com.android.support', module: 'support-annotations'
55 | })
56 |
57 | compile 'com.android.support:appcompat-v7:25.3.1'
58 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
59 |
60 | compile project(':lib')
61 |
62 | testCompile 'junit:junit:4.12'
63 | }
64 |
65 | // Copy output files to '/bin' after build --------------
66 | task copyOutputFiles(type: Copy) {
67 | from 'build/outputs/apk'
68 | into "../bin"
69 | include '*.apk'
70 | }
71 |
72 | build.finalizedBy(copyOutputFiles)
73 | // ------------------------------------------------------
--------------------------------------------------------------------------------
/examples/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/examples/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
16 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
28 |
29 |
32 |
33 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/examples/src/main/java/ai/olami/android/example/Config.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2017, VIA Technologies, Inc. & OLAMI Team.
3 |
4 | http://olami.ai
5 |
6 | Licensed under the Apache License, Version 2.0 (the "License");
7 | you may not use this file except in compliance with the License.
8 | You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing, software
13 | distributed under the License is distributed on an "AS IS" BASIS,
14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | See the License for the specific language governing permissions and
16 | limitations under the License.
17 | */
18 |
19 | package ai.olami.android.example;
20 |
21 | import ai.olami.cloudService.APIConfiguration;
22 |
23 | public class Config {
24 |
25 | // * Replace your APP KEY with this variable.
26 | private static String mAppKey = "*****your-app-key*****";
27 | public static void setAppKey(String appKey) {
28 | mAppKey = appKey;
29 | }
30 | public static String getAppKey() {
31 | return mAppKey;
32 | }
33 |
34 | // * Replace your APP SECRET with this variable.
35 | private static String mAppSecret = "*****your-app-secret*****";
36 | public static void setAppSecret(String appSecret) {
37 | mAppSecret = appSecret;
38 | }
39 | public static String getAppSecret() {
40 | return mAppSecret;
41 | }
42 |
43 | // * Replace the localize option you want with this variable.
44 | // * - Use LOCALIZE_OPTION_SIMPLIFIED_CHINESE for China
45 | // * - Use LOCALIZE_OPTION_TRADITIONAL_CHINESE for Taiwan
46 | private static int mLocalizeOption = APIConfiguration.LOCALIZE_OPTION_SIMPLIFIED_CHINESE;
47 | // private static int mLocalizeOption = APIConfiguration.LOCALIZE_OPTION_TRADITIONAL_CHINESE;
48 | public static void setLocalizeOption(int localizeOption) {
49 | mLocalizeOption = localizeOption;
50 | }
51 | public static int getLocalizeOption() {
52 | return mLocalizeOption;
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/examples/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/examples/src/main/res/layout/activity_speech_input.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
24 |
25 |
35 |
36 |
47 |
48 |
62 |
63 |
75 |
76 |
88 |
89 |
101 |
102 |
113 |
114 |
125 |
126 |
135 |
136 |
137 |
--------------------------------------------------------------------------------
/examples/src/main/res/layout/activity_text_input_nli_analysis.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
24 |
25 |
36 |
37 |
46 |
47 |
57 |
58 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/examples/src/main/res/layout/activity_text_input_word_segmentation.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
24 |
25 |
36 |
37 |
46 |
47 |
57 |
58 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/examples/src/main/res/layout/configuration_setting.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
15 |
16 |
27 |
28 |
40 |
--------------------------------------------------------------------------------
/examples/src/main/res/menu/menu.xml:
--------------------------------------------------------------------------------
1 |
16 |
--------------------------------------------------------------------------------
/examples/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olami-developers/olami-android-client-sdk/278054f18655af66421bd59f2704485e730c7d70/examples/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olami-developers/olami-android-client-sdk/278054f18655af66421bd59f2704485e730c7d70/examples/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/src/main/res/mipmap-hdpi/microphone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olami-developers/olami-android-client-sdk/278054f18655af66421bd59f2704485e730c7d70/examples/src/main/res/mipmap-hdpi/microphone.png
--------------------------------------------------------------------------------
/examples/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olami-developers/olami-android-client-sdk/278054f18655af66421bd59f2704485e730c7d70/examples/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olami-developers/olami-android-client-sdk/278054f18655af66421bd59f2704485e730c7d70/examples/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olami-developers/olami-android-client-sdk/278054f18655af66421bd59f2704485e730c7d70/examples/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olami-developers/olami-android-client-sdk/278054f18655af66421bd59f2704485e730c7d70/examples/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olami-developers/olami-android-client-sdk/278054f18655af66421bd59f2704485e730c7d70/examples/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olami-developers/olami-android-client-sdk/278054f18655af66421bd59f2704485e730c7d70/examples/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olami-developers/olami-android-client-sdk/278054f18655af66421bd59f2704485e730c7d70/examples/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olami-developers/olami-android-client-sdk/278054f18655af66421bd59f2704485e730c7d70/examples/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/src/main/res/values-en/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Olami Android Sample Code
4 | Start
5 | Stop
6 | Stopped
7 | Initializing
8 | Initialized
9 | Recording
10 | Error
11 | Stopping
12 | Stopped
13 | Processing
14 | Completed
15 | Error
16 | RecognizeState
17 | RecordState
18 | Speech to text
19 | Volume
20 | Speech Input
21 | Text Input
22 | Word Segmentation
23 | NLI Analysis
24 | Type in your text
25 | Submit
26 | Response
27 | Result
28 | Setting
29 | Change Language
30 | Change to Simplified Chinese service
31 | Change to Traditional Chinese service
32 | * Use different user account and keys when you change language service.
33 | Please type in AppKey and AppSecret
34 | Cancel
35 | Please type in
36 | Register Developer (olami.ai)
37 | Please type in AppKey and AppSecret
38 | Getting microphone permission denied
39 | Getting microphone permission success
40 | Getting write storage permission success
41 | Getting write storage permission denied
42 | Auto Stop
43 |
--------------------------------------------------------------------------------
/examples/src/main/res/values-zh-rTW/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 開始
4 | OLAMI - Android 範例程式
5 | 停止
6 | 停止
7 | 初始化
8 | 初始化完成
9 | 錄音中
10 | 錯誤
11 | 停止中
12 | 停止
13 | 辨識中
14 | 辨識完成
15 | 錯誤
16 | 辨識狀態
17 | 錄音狀態
18 | 語音辨識
19 | 音量
20 | 語音輸入
21 | 文字輸入
22 | 文字分詞
23 | 自然語言語意理解
24 | 請輸入文字
25 | 送出
26 | 返回結果
27 | 結果
28 | 設定
29 | 選擇語言
30 | 切換至「簡體中文伺服器」
31 | 切換至「繁體中文伺服器」
32 | * 選擇簡體或繁體中文服務時, 應使用其對應的開發者帳號和KEY
33 | 請輸入AppKey和AppSecret
34 | 取消
35 | 請輸入
36 | 註冊開發者(前往官網)
37 | 請輸入有效的Appkey和AppSecret
38 | 取得麥克風權限失敗
39 | 取得麥克風權限成功
40 | 取得寫入外部裝置權限成功
41 | 取得寫入外部裝置權限失敗
42 | 自動停止
43 |
--------------------------------------------------------------------------------
/examples/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/examples/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 欧拉蜜 - 安卓示例程序
3 | 开始
4 | 停止
5 | 停止
6 | 初始化
7 | 初始化完成
8 | 录音中
9 | 错误
10 | 停止中
11 | 停止
12 | 识别中
13 | 识别完成
14 | 错误
15 | 识别状态
16 | 录音状态
17 | 语音识别
18 | 音量
19 | 语音输入
20 | 文字输入
21 | 文字分词
22 | 自然语言语义理解
23 | 请输入文字
24 | 提交
25 | 返回结果
26 | 结果
27 | 设定
28 | 选择语言
29 | 切换至「简体中文服务器」
30 | 切换至「繁体中文服务器」
31 | * 选择简体或繁体中文服务时, 应使用其对应的开发者帐号和KEY
32 | 请输入AppKey和AppSecret
33 | 取消
34 | 请输入
35 | 注册开发者(前往官网)
36 | 请输入有效的Appkey和AppSecret
37 | 取得麦克风权限失败
38 | 取得麦克风权限成功
39 | 取得写入外部装置权限成功
40 | 取得写入外部装置权限失败
41 | 自动停止
42 |
43 |
--------------------------------------------------------------------------------
/examples/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olami-developers/olami-android-client-sdk/278054f18655af66421bd59f2704485e730c7d70/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri May 26 11:16:25 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/lib/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/lib/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # For more information about using CMake with Android Studio, read the
2 | # documentation: https://d.android.com/studio/projects/add-native-code.html
3 |
4 | # Sets the minimum version of CMake required to build the native library.
5 |
6 | cmake_minimum_required(VERSION 3.4.1)
7 |
8 | # Creates and names a library, sets it as either STATIC
9 | # or SHARED, and provides the relative paths to its source code.
10 | # You can define multiple libraries, and CMake builds them for you.
11 | # Gradle automatically packages shared libraries with your APK.
12 |
13 | add_library( # Sets the name of the library.
14 | native-lib
15 |
16 | # Sets the library as a shared library.
17 | SHARED
18 |
19 | # Provides a relative path to your source file(s).
20 | src/main/cpp/native-lib.cpp )
21 |
22 | # Searches for a specified prebuilt library and stores the path as a
23 | # variable. Because CMake includes system libraries in the search path by
24 | # default, you only need to specify the name of the public NDK library
25 | # you want to add. CMake verifies that the library exists before
26 | # completing its build.
27 |
28 | find_library( # Sets the name of the path variable.
29 | log-lib
30 |
31 | # Specifies the name of the NDK library that
32 | # you want CMake to locate.
33 | log )
34 |
35 | # Specifies libraries CMake should link to your target library. You
36 | # can link multiple libraries, such as libraries you define in this
37 | # build script, prebuilt third-party libraries, or system libraries.
38 |
39 | target_link_libraries( # Specifies the target library.
40 | native-lib
41 |
42 | # Links the target library to the log library
43 | # included in the NDK.
44 | ${log-lib} )
45 |
46 | ADD_SUBDIRECTORY(src/main/cpp/speex)
--------------------------------------------------------------------------------
/lib/libs/olami-java-client-1.5.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olami-developers/olami-android-client-sdk/278054f18655af66421bd59f2704485e730c7d70/lib/libs/olami-java-client-1.5.1.jar
--------------------------------------------------------------------------------
/lib/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/lib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/native-lib.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018, VIA Technologies, Inc. & OLAMI Team.
3 |
4 | http://olami.ai
5 |
6 | Licensed under the Apache License, Version 2.0 (the "License");
7 | you may not use this file except in compliance with the License.
8 | You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing, software
13 | distributed under the License is distributed on an "AS IS" BASIS,
14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | See the License for the specific language governing permissions and
16 | limitations under the License.
17 | */
18 |
19 | #include
20 | #include
21 |
22 | extern "C"
23 | JNIEXPORT jstring JNICALL
24 | Java_jnibuilder_app_olami_ai_androidjnibuilder_MainActivity_stringFromJNI(
25 | JNIEnv *env,
26 | jobject /* this */) {
27 | std::string hello = "Hello from C++";
28 | return env->NewStringUTF(hello.c_str());
29 | }
30 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # For more information about using CMake with Android Studio, read the
2 | # documentation: https://d.android.com/studio/projects/add-native-code.html
3 |
4 | # Sets the minimum version of CMake required to build the native library.
5 |
6 | cmake_minimum_required(VERSION 3.4.1)
7 |
8 | SET(SOURCE_FILES
9 | libspeex/kiss_fft.c libspeex/kiss_fftr.c
10 | libspeex/cb_search.c libspeex/exc_10_32_table.c libspeex/exc_8_128_table.c
11 | libspeex/filters.c libspeex/gain_table.c libspeex/hexc_table.c libspeex/high_lsp_tables.c libspeex/lsp.c
12 | libspeex/ltp.c libspeex/speex.c libspeex/stereo.c libspeex/vbr.c libspeex/vq.c libspeex/bits.c libspeex/exc_10_16_table.c
13 | libspeex/exc_20_32_table.c libspeex/exc_5_256_table.c libspeex/exc_5_64_table.c libspeex/gain_table_lbr.c libspeex/hexc_10_32_table.c
14 | libspeex/lpc.c libspeex/lsp_tables_nb.c libspeex/modes.c libspeex/modes_wb.c libspeex/nb_celp.c libspeex/quant_lsp.c libspeex/sb_celp.c
15 | libspeex/speex_callbacks.c libspeex/speex_header.c libspeex/window.c
16 | speex_jni.cpp
17 | )
18 | INCLUDE_DIRECTORIES(include)
19 | set(CMAKE_BUILD_TYPE Release)
20 | SET(CMAKE_C_FLAGS_DEBUG "-DFLOATING_POINT -DUSE_KISS_FFT -DEXPORT=\"\" -UHAVE_CONFIG_H")
21 | SET(CMAKE_C_FLAGS_RELEASE "-DFLOATING_POINT -DUSE_KISS_FFT -DEXPORT=\"\" -UHAVE_CONFIG_H")
22 |
23 | add_library( speexjni SHARED ${SOURCE_FILES})
24 | # find_library( log-lib log )
25 | # target_link_libraries( speex ${log-lib} )
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/include/speex/speex_callbacks.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2002 Jean-Marc Valin*/
2 | /**
3 | @file speex_callbacks.h
4 | @brief Describes callback handling and in-band signalling
5 | */
6 | /*
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | - Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 |
14 | - Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions and the following disclaimer in the
16 | documentation and/or other materials provided with the distribution.
17 |
18 | - Neither the name of the Xiph.org Foundation nor the names of its
19 | contributors may be used to endorse or promote products derived from
20 | this software without specific prior written permission.
21 |
22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 |
34 | */
35 |
36 | #ifndef SPEEX_CALLBACKS_H
37 | #define SPEEX_CALLBACKS_H
38 | /** @defgroup SpeexCallbacks Various definitions for Speex callbacks supported by the decoder.
39 | * @{
40 | */
41 |
42 | #include "speex.h"
43 |
44 | #ifdef __cplusplus
45 | extern "C" {
46 | #endif
47 |
48 | /** Total number of callbacks */
49 | #define SPEEX_MAX_CALLBACKS 16
50 |
51 | /* Describes all the in-band requests */
52 |
53 | /*These are 1-bit requests*/
54 | /** Request for perceptual enhancement (1 for on, 0 for off) */
55 | #define SPEEX_INBAND_ENH_REQUEST 0
56 | /** Reserved */
57 | #define SPEEX_INBAND_RESERVED1 1
58 |
59 | /*These are 4-bit requests*/
60 | /** Request for a mode change */
61 | #define SPEEX_INBAND_MODE_REQUEST 2
62 | /** Request for a low mode change */
63 | #define SPEEX_INBAND_LOW_MODE_REQUEST 3
64 | /** Request for a high mode change */
65 | #define SPEEX_INBAND_HIGH_MODE_REQUEST 4
66 | /** Request for VBR (1 on, 0 off) */
67 | #define SPEEX_INBAND_VBR_QUALITY_REQUEST 5
68 | /** Request to be sent acknowledge */
69 | #define SPEEX_INBAND_ACKNOWLEDGE_REQUEST 6
70 | /** Request for VBR (1 for on, 0 for off) */
71 | #define SPEEX_INBAND_VBR_REQUEST 7
72 |
73 | /*These are 8-bit requests*/
74 | /** Send a character in-band */
75 | #define SPEEX_INBAND_CHAR 8
76 | /** Intensity stereo information */
77 | #define SPEEX_INBAND_STEREO 9
78 |
79 | /*These are 16-bit requests*/
80 | /** Transmit max bit-rate allowed */
81 | #define SPEEX_INBAND_MAX_BITRATE 10
82 |
83 | /*These are 32-bit requests*/
84 | /** Acknowledge packet reception */
85 | #define SPEEX_INBAND_ACKNOWLEDGE 12
86 |
87 | /** Callback function type */
88 | typedef int (*speex_callback_func)(SpeexBits *bits, void *state, void *data);
89 |
90 | /** Callback information */
91 | typedef struct SpeexCallback {
92 | int callback_id; /**< ID associated to the callback */
93 | speex_callback_func func; /**< Callback handler function */
94 | void *data; /**< Data that will be sent to the handler */
95 | void *reserved1; /**< Reserved for future use */
96 | int reserved2; /**< Reserved for future use */
97 | } SpeexCallback;
98 |
99 | /** Handle in-band request */
100 | int speex_inband_handler(SpeexBits *bits, SpeexCallback *callback_list, void *state);
101 |
102 | /** Standard handler for mode request (change mode, no questions asked) */
103 | int speex_std_mode_request_handler(SpeexBits *bits, void *state, void *data);
104 |
105 | /** Standard handler for high mode request (change high mode, no questions asked) */
106 | int speex_std_high_mode_request_handler(SpeexBits *bits, void *state, void *data);
107 |
108 | /** Standard handler for in-band characters (write to stderr) */
109 | int speex_std_char_handler(SpeexBits *bits, void *state, void *data);
110 |
111 | /** Default handler for user-defined requests: in this case, just ignore */
112 | int speex_default_user_handler(SpeexBits *bits, void *state, void *data);
113 |
114 |
115 |
116 | /** Standard handler for low mode request (change low mode, no questions asked) */
117 | int speex_std_low_mode_request_handler(SpeexBits *bits, void *state, void *data);
118 |
119 | /** Standard handler for VBR request (Set VBR, no questions asked) */
120 | int speex_std_vbr_request_handler(SpeexBits *bits, void *state, void *data);
121 |
122 | /** Standard handler for enhancer request (Turn enhancer on/off, no questions asked) */
123 | int speex_std_enh_request_handler(SpeexBits *bits, void *state, void *data);
124 |
125 | /** Standard handler for VBR quality request (Set VBR quality, no questions asked) */
126 | int speex_std_vbr_quality_request_handler(SpeexBits *bits, void *state, void *data);
127 |
128 |
129 | #ifdef __cplusplus
130 | }
131 | #endif
132 |
133 | /** @} */
134 | #endif
135 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/include/speex/speex_config_types.h:
--------------------------------------------------------------------------------
1 | #ifndef __SPEEX_TYPES_H__
2 | #define __SPEEX_TYPES_H__
3 |
4 | typedef short spx_int16_t;
5 | typedef unsigned short spx_uint16_t;
6 | typedef int spx_int32_t;
7 | typedef unsigned int spx_uint32_t;
8 |
9 | #endif
10 |
11 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/include/speex/speex_config_types.h.bak:
--------------------------------------------------------------------------------
1 | #ifndef __SPEEX_TYPES_H__
2 | #define __SPEEX_TYPES_H__
3 |
4 | @INCLUDE_STDINT@
5 |
6 | typedef @SIZE16@ spx_int16_t;
7 | typedef @USIZE16@ spx_uint16_t;
8 | typedef @SIZE32@ spx_int32_t;
9 | typedef @USIZE32@ spx_uint32_t;
10 |
11 | #endif
12 |
13 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/include/speex/speex_header.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2002 Jean-Marc Valin */
2 | /**
3 | @file speex_header.h
4 | @brief Describes the Speex header
5 | */
6 | /*
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | - Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 |
14 | - Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions and the following disclaimer in the
16 | documentation and/or other materials provided with the distribution.
17 |
18 | - Neither the name of the Xiph.org Foundation nor the names of its
19 | contributors may be used to endorse or promote products derived from
20 | this software without specific prior written permission.
21 |
22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 |
34 | */
35 |
36 |
37 | #ifndef SPEEX_HEADER_H
38 | #define SPEEX_HEADER_H
39 | /** @defgroup SpeexHeader SpeexHeader: Makes it easy to write/parse an Ogg/Speex header
40 | * This is the Speex header for the Ogg encapsulation. You don't need that if you just use RTP.
41 | * @{
42 | */
43 |
44 | #include "speex_types.h"
45 |
46 | #ifdef __cplusplus
47 | extern "C" {
48 | #endif
49 |
50 | struct SpeexMode;
51 |
52 | /** Length of the Speex header identifier */
53 | #define SPEEX_HEADER_STRING_LENGTH 8
54 |
55 | /** Maximum number of characters for encoding the Speex version number in the header */
56 | #define SPEEX_HEADER_VERSION_LENGTH 20
57 |
58 | /** Speex header info for file-based formats */
59 | typedef struct SpeexHeader {
60 | char speex_string[SPEEX_HEADER_STRING_LENGTH]; /**< Identifies a Speex bit-stream, always set to "Speex " */
61 | char speex_version[SPEEX_HEADER_VERSION_LENGTH]; /**< Speex version */
62 | spx_int32_t speex_version_id; /**< Version for Speex (for checking compatibility) */
63 | spx_int32_t header_size; /**< Total size of the header ( sizeof(SpeexHeader) ) */
64 | spx_int32_t rate; /**< Sampling rate used */
65 | spx_int32_t mode; /**< Mode used (0 for narrowband, 1 for wideband) */
66 | spx_int32_t mode_bitstream_version; /**< Version ID of the bit-stream */
67 | spx_int32_t nb_channels; /**< Number of channels encoded */
68 | spx_int32_t bitrate; /**< Bit-rate used */
69 | spx_int32_t frame_size; /**< Size of frames */
70 | spx_int32_t vbr; /**< 1 for a VBR encoding, 0 otherwise */
71 | spx_int32_t frames_per_packet; /**< Number of frames stored per Ogg packet */
72 | spx_int32_t extra_headers; /**< Number of additional headers after the comments */
73 | spx_int32_t reserved1; /**< Reserved for future use, must be zero */
74 | spx_int32_t reserved2; /**< Reserved for future use, must be zero */
75 | } SpeexHeader;
76 |
77 | /** Initializes a SpeexHeader using basic information */
78 | void speex_init_header(SpeexHeader *header, int rate, int nb_channels, const struct SpeexMode *m);
79 |
80 | /** Creates the header packet from the header itself (mostly involves endianness conversion) */
81 | char *speex_header_to_packet(SpeexHeader *header, int *size);
82 |
83 | /** Creates a SpeexHeader from a packet */
84 | SpeexHeader *speex_packet_to_header(char *packet, int size);
85 |
86 | /** Frees the memory allocated by either speex_header_to_packet() or speex_packet_to_header() */
87 | void speex_header_free(void *ptr);
88 |
89 | #ifdef __cplusplus
90 | }
91 | #endif
92 |
93 | /** @} */
94 | #endif
95 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/include/speex/speex_stereo.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2002 Jean-Marc Valin*/
2 | /**
3 | @file speex_stereo.h
4 | @brief Describes the handling for intensity stereo
5 | */
6 | /*
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | - Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 |
14 | - Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions and the following disclaimer in the
16 | documentation and/or other materials provided with the distribution.
17 |
18 | - Neither the name of the Xiph.org Foundation nor the names of its
19 | contributors may be used to endorse or promote products derived from
20 | this software without specific prior written permission.
21 |
22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef STEREO_H
36 | #define STEREO_H
37 | /** @defgroup SpeexStereoState SpeexStereoState: Handling Speex stereo files
38 | * This describes the Speex intensity stereo encoding/decoding
39 | * @{
40 | */
41 |
42 | #include "speex_types.h"
43 | #include "speex_bits.h"
44 |
45 |
46 | #ifdef __cplusplus
47 | extern "C" {
48 | #endif
49 |
50 | /** If you access any of these fields directly, I'll personally come and bite you */
51 | typedef struct SpeexStereoState {
52 | float balance; /**< Left/right balance info */
53 | float e_ratio; /**< Ratio of energies: E(left+right)/[E(left)+E(right)] */
54 | float smooth_left; /**< Smoothed left channel gain */
55 | float smooth_right; /**< Smoothed right channel gain */
56 | float reserved1; /**< Reserved for future use */
57 | float reserved2; /**< Reserved for future use */
58 | } SpeexStereoState;
59 |
60 | /** Deprecated. Use speex_stereo_state_init() instead. */
61 | #define SPEEX_STEREO_STATE_INIT {1,.5,1,1,0,0}
62 |
63 | /** Initialise/create a stereo stereo state */
64 | SpeexStereoState *speex_stereo_state_init();
65 |
66 | /** Reset/re-initialise an already allocated stereo state */
67 | void speex_stereo_state_reset(SpeexStereoState *stereo);
68 |
69 | /** Destroy a stereo stereo state */
70 | void speex_stereo_state_destroy(SpeexStereoState *stereo);
71 |
72 | /** Transforms a stereo frame into a mono frame and stores intensity stereo info in 'bits' */
73 | void speex_encode_stereo(float *data, int frame_size, SpeexBits *bits);
74 |
75 | /** Transforms a stereo frame into a mono frame and stores intensity stereo info in 'bits' */
76 | void speex_encode_stereo_int(spx_int16_t *data, int frame_size, SpeexBits *bits);
77 |
78 | /** Transforms a mono frame into a stereo frame using intensity stereo info */
79 | void speex_decode_stereo(float *data, int frame_size, SpeexStereoState *stereo);
80 |
81 | /** Transforms a mono frame into a stereo frame using intensity stereo info */
82 | void speex_decode_stereo_int(spx_int16_t *data, int frame_size, SpeexStereoState *stereo);
83 |
84 | /** Callback handler for intensity stereo info */
85 | int speex_std_stereo_request_handler(SpeexBits *bits, void *state, void *data);
86 |
87 | #ifdef __cplusplus
88 | }
89 | #endif
90 |
91 | /** @} */
92 | #endif
93 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/include/speex/speex_types.h:
--------------------------------------------------------------------------------
1 | /* speex_types.h taken from libogg */
2 | /********************************************************************
3 | * *
4 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 | * *
9 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
10 | * by the Xiph.Org Foundation http://www.xiph.org/ *
11 | * *
12 | ********************************************************************
13 |
14 | function: #ifdef jail to whip a few platforms into the UNIX ideal.
15 | last mod: $Id: os_types.h 7524 2004-08-11 04:20:36Z conrad $
16 |
17 | ********************************************************************/
18 | /**
19 | @file speex_types.h
20 | @brief Speex types
21 | */
22 | #ifndef _SPEEX_TYPES_H
23 | #define _SPEEX_TYPES_H
24 |
25 | #if defined(_WIN32)
26 |
27 | # if defined(__CYGWIN__)
28 | # include <_G_config.h>
29 | typedef _G_int32_t spx_int32_t;
30 | typedef _G_uint32_t spx_uint32_t;
31 | typedef _G_int16_t spx_int16_t;
32 | typedef _G_uint16_t spx_uint16_t;
33 | # elif defined(__MINGW32__)
34 | typedef short spx_int16_t;
35 | typedef unsigned short spx_uint16_t;
36 | typedef int spx_int32_t;
37 | typedef unsigned int spx_uint32_t;
38 | # elif defined(__MWERKS__)
39 | typedef int spx_int32_t;
40 | typedef unsigned int spx_uint32_t;
41 | typedef short spx_int16_t;
42 | typedef unsigned short spx_uint16_t;
43 | # else
44 | /* MSVC/Borland */
45 | typedef __int32 spx_int32_t;
46 | typedef unsigned __int32 spx_uint32_t;
47 | typedef __int16 spx_int16_t;
48 | typedef unsigned __int16 spx_uint16_t;
49 | # endif
50 |
51 | #elif defined(__MACOS__)
52 |
53 | # include
54 | typedef SInt16 spx_int16_t;
55 | typedef UInt16 spx_uint16_t;
56 | typedef SInt32 spx_int32_t;
57 | typedef UInt32 spx_uint32_t;
58 |
59 | #elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */
60 |
61 | # include
62 | typedef int16_t spx_int16_t;
63 | typedef u_int16_t spx_uint16_t;
64 | typedef int32_t spx_int32_t;
65 | typedef u_int32_t spx_uint32_t;
66 |
67 | #elif defined(__BEOS__)
68 |
69 | /* Be */
70 | # include
71 | typedef int16_t spx_int16_t;
72 | typedef u_int16_t spx_uint16_t;
73 | typedef int32_t spx_int32_t;
74 | typedef u_int32_t spx_uint32_t;
75 |
76 | #elif defined (__EMX__)
77 |
78 | /* OS/2 GCC */
79 | typedef short spx_int16_t;
80 | typedef unsigned short spx_uint16_t;
81 | typedef int spx_int32_t;
82 | typedef unsigned int spx_uint32_t;
83 |
84 | #elif defined (DJGPP)
85 |
86 | /* DJGPP */
87 | typedef short spx_int16_t;
88 | typedef int spx_int32_t;
89 | typedef unsigned int spx_uint32_t;
90 |
91 | #elif defined(R5900)
92 |
93 | /* PS2 EE */
94 | typedef int spx_int32_t;
95 | typedef unsigned spx_uint32_t;
96 | typedef short spx_int16_t;
97 |
98 | #elif defined(__SYMBIAN32__)
99 |
100 | /* Symbian GCC */
101 | typedef signed short spx_int16_t;
102 | typedef unsigned short spx_uint16_t;
103 | typedef signed int spx_int32_t;
104 | typedef unsigned int spx_uint32_t;
105 |
106 | #elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X)
107 |
108 | typedef short spx_int16_t;
109 | typedef unsigned short spx_uint16_t;
110 | typedef long spx_int32_t;
111 | typedef unsigned long spx_uint32_t;
112 |
113 | #elif defined(CONFIG_TI_C6X)
114 |
115 | typedef short spx_int16_t;
116 | typedef unsigned short spx_uint16_t;
117 | typedef int spx_int32_t;
118 | typedef unsigned int spx_uint32_t;
119 |
120 | #else
121 |
122 | #include "speex_config_types.h"
123 |
124 | #endif
125 |
126 | #endif /* _SPEEX_TYPES_H */
127 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/bfin.h:
--------------------------------------------------------------------------------
1 | /* Common Blackfin assembly defines
2 | *
3 | * Copyright (C) 2005-2009 Analog Devices
4 | */
5 |
6 | #if __GNUC__ <= 3
7 | /* GCC-3.4 and older did not use hardware loops and thus did not have
8 | * register constraints for declaring clobbers.
9 | */
10 | # define BFIN_HWLOOP0_REGS
11 | # define BFIN_HWLOOP1_REGS
12 | #else
13 | # define BFIN_HWLOOP0_REGS , "LB0", "LT0", "LC0"
14 | # define BFIN_HWLOOP1_REGS , "LB1", "LT1", "LC1"
15 | #endif
16 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/cb_search.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2002 Jean-Marc Valin & David Rowe */
2 | /**
3 | @file cb_search.h
4 | @brief Overlapped codebook search
5 | */
6 | /*
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | - Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 |
14 | - Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions and the following disclaimer in the
16 | documentation and/or other materials provided with the distribution.
17 |
18 | - Neither the name of the Xiph.org Foundation nor the names of its
19 | contributors may be used to endorse or promote products derived from
20 | this software without specific prior written permission.
21 |
22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef CB_SEARCH_H
36 | #define CB_SEARCH_H
37 |
38 | #include "speex/speex_bits.h"
39 | #include "arch.h"
40 |
41 | /** Split codebook parameters. */
42 | typedef struct split_cb_params {
43 | int subvect_size;
44 | int nb_subvect;
45 | const signed char *shape_cb;
46 | int shape_bits;
47 | int have_sign;
48 | } split_cb_params;
49 |
50 |
51 | void split_cb_search_shape_sign(
52 | spx_word16_t target[], /* target vector */
53 | spx_coef_t ak[], /* LPCs for this subframe */
54 | spx_coef_t awk1[], /* Weighted LPCs for this subframe */
55 | spx_coef_t awk2[], /* Weighted LPCs for this subframe */
56 | const void *par, /* Codebook/search parameters */
57 | int p, /* number of LPC coeffs */
58 | int nsf, /* number of samples in subframe */
59 | spx_sig_t *exc,
60 | spx_word16_t *r,
61 | SpeexBits *bits,
62 | char *stack,
63 | int complexity,
64 | int update_target
65 | );
66 |
67 | void split_cb_shape_sign_unquant(
68 | spx_sig_t *exc,
69 | const void *par, /* non-overlapping codebook */
70 | int nsf, /* number of samples in subframe */
71 | SpeexBits *bits,
72 | char *stack,
73 | spx_int32_t *seed
74 | );
75 |
76 |
77 | void noise_codebook_quant(
78 | spx_word16_t target[], /* target vector */
79 | spx_coef_t ak[], /* LPCs for this subframe */
80 | spx_coef_t awk1[], /* Weighted LPCs for this subframe */
81 | spx_coef_t awk2[], /* Weighted LPCs for this subframe */
82 | const void *par, /* Codebook/search parameters */
83 | int p, /* number of LPC coeffs */
84 | int nsf, /* number of samples in subframe */
85 | spx_sig_t *exc,
86 | spx_word16_t *r,
87 | SpeexBits *bits,
88 | char *stack,
89 | int complexity,
90 | int update_target
91 | );
92 |
93 |
94 | void noise_codebook_unquant(
95 | spx_sig_t *exc,
96 | const void *par, /* non-overlapping codebook */
97 | int nsf, /* number of samples in subframe */
98 | SpeexBits *bits,
99 | char *stack,
100 | spx_int32_t *seed
101 | );
102 |
103 | #endif
104 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/cb_search_arm4.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2004 Jean-Marc Valin */
2 | /**
3 | @file cb_search_arm4.h
4 | @brief Fixed codebook functions (ARM4 version)
5 | */
6 | /*
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | - Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 |
14 | - Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions and the following disclaimer in the
16 | documentation and/or other materials provided with the distribution.
17 |
18 | - Neither the name of the Xiph.org Foundation nor the names of its
19 | contributors may be used to endorse or promote products derived from
20 | this software without specific prior written permission.
21 |
22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | /* This optimization is temporaly disabled until it is fixed to account for the fact
36 | that "r" is now a 16-bit array */
37 | #if 0
38 | #define OVERRIDE_COMPUTE_WEIGHTED_CODEBOOK
39 | static void compute_weighted_codebook(const signed char *shape_cb, const spx_word16_t *r, spx_word16_t *resp, spx_word16_t *resp2, spx_word32_t *E, int shape_cb_size, int subvect_size, char *stack)
40 | {
41 | int i, j, k;
42 | //const signed char *shape;
43 | for (i=0;i>>= 13;\n\t"
67 | "A1 += R0.L*R0.L (IS);\n\t"
68 | "W[P3++] = R0;\n\t"
69 | "P0 += 1;\n\t"
70 | "P2 += 2;\n\t"
71 | "LOOP_END outter%=;\n\t"
72 | "P4 = %4;\n\t"
73 | "R1 = A1;\n\t"
74 | "[P4] = R1;\n\t"
75 | :
76 | : "m" (subvect_size), "m" (shape_cb), "m" (r), "m" (resp), "m" (E)
77 | : "A0", "P0", "P1", "P2", "P3", "P4", "R0", "R1", "R2", "I0", "I1", "L0",
78 | "L1", "A0", "A1", "memory", "ASTAT" BFIN_HWLOOP0_REGS BFIN_HWLOOP1_REGS
79 | );
80 | shape_cb += subvect_size;
81 | resp += subvect_size;
82 | E++;
83 | }
84 | }
85 |
86 | #define OVERRIDE_TARGET_UPDATE
87 | static inline void target_update(spx_word16_t *t, spx_word16_t g, spx_word16_t *r, int len)
88 | {
89 | if (!len)
90 | return;
91 | __asm__ __volatile__
92 | (
93 | "I0 = %0;\n\t"
94 | "I1 = %1;\n\t"
95 | "L0 = 0;\n\t"
96 | "L1 = 0;\n\t"
97 | "R2 = 4096;\n\t"
98 | "LOOP tupdate%= LC0 = %3;\n\t"
99 | "LOOP_BEGIN tupdate%=;\n\t"
100 | "R0.L = W[I0] || R1.L = W[I1++];\n\t"
101 | "R1 = (A1 = R1.L*%2.L) (IS);\n\t"
102 | "R1 = R1 + R2;\n\t"
103 | "R1 >>>= 13;\n\t"
104 | "R0.L = R0.L - R1.L;\n\t"
105 | "W[I0++] = R0.L;\n\t"
106 | "LOOP_END tupdate%=;\n\t"
107 | :
108 | : "a" (t), "a" (r), "d" (g), "a" (len)
109 | : "R0", "R1", "R2", "A1", "I0", "I1", "L0", "L1", "ASTAT" BFIN_HWLOOP0_REGS
110 | );
111 | }
112 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/cb_search_sse.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2004 Jean-Marc Valin */
2 | /**
3 | @file cb_search_sse.h
4 | @brief Fixed codebook functions (SSE version)
5 | */
6 | /*
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | - Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 |
14 | - Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions and the following disclaimer in the
16 | documentation and/or other materials provided with the distribution.
17 |
18 | - Neither the name of the Xiph.org Foundation nor the names of its
19 | contributors may be used to endorse or promote products derived from
20 | this software without specific prior written permission.
21 |
22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #include
36 |
37 | static inline void _spx_mm_getr_ps (__m128 U, float *__Z, float *__Y, float *__X, float *__W)
38 | {
39 | union {
40 | float __a[4];
41 | __m128 __v;
42 | } __u;
43 |
44 | __u.__v = U;
45 |
46 | *__Z = __u.__a[0];
47 | *__Y = __u.__a[1];
48 | *__X = __u.__a[2];
49 | *__W = __u.__a[3];
50 |
51 | }
52 |
53 | #define OVERRIDE_COMPUTE_WEIGHTED_CODEBOOK
54 | static void compute_weighted_codebook(const signed char *shape_cb, const spx_sig_t *_r, float *resp, __m128 *resp2, __m128 *E, int shape_cb_size, int subvect_size, char *stack)
55 | {
56 | int i, j, k;
57 | __m128 resj, EE;
58 | VARDECL(__m128 *r);
59 | VARDECL(__m128 *shape);
60 | ALLOC(r, subvect_size, __m128);
61 | ALLOC(shape, subvect_size, __m128);
62 | for(j=0;j>2] = EE;
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/exc_10_16_table.c:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2002 Jean-Marc Valin
2 | File: exc_10_16_table.c
3 | Codebook for excitation in narrowband CELP mode (3200 bps)
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions
7 | are met:
8 |
9 | - Redistributions of source code must retain the above copyright
10 | notice, this list of conditions and the following disclaimer.
11 |
12 | - Redistributions in binary form must reproduce the above copyright
13 | notice, this list of conditions and the following disclaimer in the
14 | documentation and/or other materials provided with the distribution.
15 |
16 | - Neither the name of the Xiph.org Foundation nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
24 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 | */
32 |
33 |
34 | const signed char exc_10_16_table[160] = {
35 | 22,39,14,44,11,35,-2,23,-4,6,
36 | 46,-28,13,-27,-23,12,4,20,-5,9,
37 | 37,-18,-23,23,0,9,-6,-20,4,-1,
38 | -17,-5,-4,17,0,1,9,-2,1,2,
39 | 2,-12,8,-25,39,15,9,16,-55,-11,
40 | 9,11,5,10,-2,-60,8,13,-6,11,
41 | -16,27,-47,-12,11,1,16,-7,9,-3,
42 | -29,9,-14,25,-19,34,36,12,40,-10,
43 | -3,-24,-14,-37,-21,-35,-2,-36,3,-6,
44 | 67,28,6,-17,-3,-12,-16,-15,-17,-7,
45 | -59,-36,-13,1,7,1,2,10,2,11,
46 | 13,10,8,-2,7,3,5,4,2,2,
47 | -3,-8,4,-5,6,7,-42,15,35,-2,
48 | -46,38,28,-20,-9,1,7,-3,0,-2,
49 | 0,0,0,0,0,0,0,0,0,0,
50 | -15,-28,52,32,5,-5,-17,-20,-10,-1};
51 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/exc_10_32_table.c:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2002 Jean-Marc Valin
2 | File: exc_10_32_table.c
3 | Codebook for excitation in narrowband CELP mode (4000 bps)
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions
7 | are met:
8 |
9 | - Redistributions of source code must retain the above copyright
10 | notice, this list of conditions and the following disclaimer.
11 |
12 | - Redistributions in binary form must reproduce the above copyright
13 | notice, this list of conditions and the following disclaimer in the
14 | documentation and/or other materials provided with the distribution.
15 |
16 | - Neither the name of the Xiph.org Foundation nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
24 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 | */
32 |
33 |
34 | const signed char exc_10_32_table[320] = {
35 | 7,17,17,27,25,22,12,4,-3,0,
36 | 28,-36,39,-24,-15,3,-9,15,-5,10,
37 | 31,-28,11,31,-21,9,-11,-11,-2,-7,
38 | -25,14,-22,31,4,-14,19,-12,14,-5,
39 | 4,-7,4,-5,9,0,-2,42,-47,-16,
40 | 1,8,0,9,23,-57,0,28,-11,6,
41 | -31,55,-45,3,-5,4,2,-2,4,-7,
42 | -3,6,-2,7,-3,12,5,8,54,-10,
43 | 8,-7,-8,-24,-25,-27,-14,-5,8,5,
44 | 44,23,5,-9,-11,-11,-13,-9,-12,-8,
45 | -29,-8,-22,6,-15,3,-12,-1,-5,-3,
46 | 34,-1,29,-16,17,-4,12,2,1,4,
47 | -2,-4,2,-1,11,-3,-52,28,30,-9,
48 | -32,25,44,-20,-24,4,6,-1,0,0,
49 | 0,0,0,0,0,0,0,0,0,0,
50 | -25,-10,22,29,13,-13,-22,-13,-4,0,
51 | -4,-16,10,15,-36,-24,28,25,-1,-3,
52 | 66,-33,-11,-15,6,0,3,4,-2,5,
53 | 24,-20,-47,29,19,-2,-4,-1,0,-1,
54 | -2,3,1,8,-11,5,5,-57,28,28,
55 | 0,-16,4,-4,12,-6,-1,2,-20,61,
56 | -9,24,-22,-42,29,6,17,8,4,2,
57 | -65,15,8,10,5,6,5,3,2,-2,
58 | -3,5,-9,4,-5,23,13,23,-3,-63,
59 | 3,-5,-4,-6,0,-3,23,-36,-46,9,
60 | 5,5,8,4,9,-5,1,-3,10,1,
61 | -6,10,-11,24,-47,31,22,-12,14,-10,
62 | 6,11,-7,-7,7,-31,51,-12,-6,7,
63 | 6,-17,9,-11,-20,52,-19,3,-6,-6,
64 | -8,-5,23,-41,37,1,-21,10,-14,8,
65 | 7,5,-15,-15,23,39,-26,-33,7,2,
66 | -32,-30,-21,-8,4,12,17,15,14,11};
67 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/exc_20_32_table.c:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2002 Jean-Marc Valin
2 | File: exc_20_32_table.c
3 | Codebook for excitation in narrowband CELP mode (2000 bps)
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions
7 | are met:
8 |
9 | - Redistributions of source code must retain the above copyright
10 | notice, this list of conditions and the following disclaimer.
11 |
12 | - Redistributions in binary form must reproduce the above copyright
13 | notice, this list of conditions and the following disclaimer in the
14 | documentation and/or other materials provided with the distribution.
15 |
16 | - Neither the name of the Xiph.org Foundation nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
24 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 | */
32 |
33 |
34 | const signed char exc_20_32_table[640] = {
35 | 12,32,25,46,36,33,9,14,-3,6,1,-8,0,-10,-5,-7,-7,-7,-5,-5,
36 | 31,-27,24,-32,-4,10,-11,21,-3,19,23,-9,22,24,-10,-1,-10,-13,-7,-11,
37 | 42,-33,31,19,-8,0,-10,-16,1,-21,-17,10,-8,14,8,4,11,-2,5,-2,
38 | -33,11,-16,33,11,-4,9,-4,11,2,6,-5,8,-5,11,-4,-6,26,-36,-16,
39 | 0,4,-2,-8,12,6,-1,34,-46,-22,9,9,21,9,5,-66,-5,26,2,10,
40 | 13,2,19,9,12,-81,3,13,13,0,-14,22,-35,6,-7,-4,6,-6,10,-6,
41 | -31,38,-33,0,-10,-11,5,-12,12,-17,5,0,-6,13,-9,10,8,25,33,2,
42 | -12,8,-6,10,-2,21,7,17,43,5,11,-7,-9,-20,-36,-20,-23,-4,-4,-3,
43 | 27,-9,-9,-49,-39,-38,-11,-9,6,5,23,25,5,3,3,4,1,2,-3,-1,
44 | 87,39,17,-21,-9,-19,-9,-15,-13,-14,-17,-11,-10,-11,-8,-6,-1,-3,-3,-1,
45 | -54,-34,-27,-8,-11,-4,-5,0,0,4,8,6,9,7,9,7,6,5,5,5,
46 | 48,10,19,-10,12,-1,9,-3,2,5,-3,2,-2,-2,0,-2,-26,6,9,-7,
47 | -16,-9,2,7,7,-5,-43,11,22,-11,-9,34,37,-15,-13,-6,1,-1,1,1,
48 | -64,56,52,-11,-27,5,4,3,1,2,1,3,-1,-4,-4,-10,-7,-4,-4,2,
49 | -1,-7,-7,-12,-10,-15,-9,-5,-5,-11,-16,-13,6,16,4,-13,-16,-10,-4,2,
50 | -47,-13,25,47,19,-14,-20,-8,-17,0,-3,-13,1,6,-17,-14,15,1,10,6,
51 | -24,0,-10,19,-69,-8,14,49,17,-5,33,-29,3,-4,0,2,-8,5,-6,2,
52 | 120,-56,-12,-47,23,-9,6,-5,1,2,-5,1,-10,4,-1,-1,4,-1,0,-3,
53 | 30,-52,-67,30,22,11,-1,-4,3,0,7,2,0,1,-10,-4,-8,-13,5,1,
54 | 1,-1,5,13,-9,-3,-10,-62,22,48,-4,-6,2,3,5,1,1,4,1,13,
55 | 3,-20,10,-9,13,-2,-4,9,-20,44,-1,20,-32,-67,19,0,28,11,8,2,
56 | -11,15,-19,-53,31,2,34,10,6,-4,-58,8,10,13,14,1,12,2,0,0,
57 | -128,37,-8,44,-9,26,-3,18,2,6,11,-1,9,1,5,3,0,1,1,2,
58 | 12,3,-2,-3,7,25,9,18,-6,-37,3,-8,-16,3,-10,-7,17,-34,-44,11,
59 | 17,-15,-3,-16,-1,-13,11,-46,-65,-2,8,13,2,4,4,5,15,5,9,6,
60 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
61 | -9,19,-12,12,-28,38,29,-1,12,2,5,23,-10,3,4,-15,21,-4,3,3,
62 | 6,17,-9,-4,-8,-20,26,5,-10,6,1,-19,18,-15,-12,47,-6,-2,-7,-9,
63 | -1,-17,-2,-2,-14,30,-14,2,-7,-4,-1,-12,11,-25,16,-3,-12,11,-7,7,
64 | -17,1,19,-28,31,-7,-10,7,-10,3,12,5,-16,6,24,41,-29,-54,0,1,
65 | 7,-1,5,-6,13,10,-4,-8,8,-9,-27,-53,-38,-1,10,19,17,16,12,12,
66 | 0,3,-7,-4,13,12,-31,-14,6,-5,3,5,17,43,50,25,10,1,-6,-2};
67 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/exc_5_64_table.c:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2002 Jean-Marc Valin
2 | File: exc_5_64_table.c
3 | Codebook for excitation in narrowband CELP mode (9600 bps)
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions
7 | are met:
8 |
9 | - Redistributions of source code must retain the above copyright
10 | notice, this list of conditions and the following disclaimer.
11 |
12 | - Redistributions in binary form must reproduce the above copyright
13 | notice, this list of conditions and the following disclaimer in the
14 | documentation and/or other materials provided with the distribution.
15 |
16 | - Neither the name of the Xiph.org Foundation nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
24 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 | */
32 |
33 |
34 | const signed char exc_5_64_table[320]={
35 | 1,5,-15,49,-66,
36 | -48,-4,50,-44,7,
37 | 37,16,-18,25,-26,
38 | -26,-15,19,19,-27,
39 | -47,28,57,5,-17,
40 | -32,-41,68,21,-2,
41 | 64,56,8,-16,-13,
42 | -26,-9,-16,11,6,
43 | -39,25,-19,22,-31,
44 | 20,-45,55,-43,10,
45 | -16,47,-40,40,-20,
46 | -51,3,-17,-14,-15,
47 | -24,53,-20,-46,46,
48 | 27,-68,32,3,-18,
49 | -5,9,-31,16,-9,
50 | -10,-1,-23,48,95,
51 | 47,25,-41,-32,-3,
52 | 15,-25,-55,36,41,
53 | -27,20,5,13,14,
54 | -22,5,2,-23,18,
55 | 46,-15,17,-18,-34,
56 | -5,-8,27,-55,73,
57 | 16,2,-1,-17,40,
58 | -78,33,0,2,19,
59 | 4,53,-16,-15,-16,
60 | -28,-3,-13,49,8,
61 | -7,-29,27,-13,32,
62 | 20,32,-61,16,14,
63 | 41,44,40,24,20,
64 | 7,4,48,-60,-77,
65 | 17,-6,-48,65,-15,
66 | 32,-30,-71,-10,-3,
67 | -6,10,-2,-7,-29,
68 | -56,67,-30,7,-5,
69 | 86,-6,-10,0,5,
70 | -31,60,34,-38,-3,
71 | 24,10,-2,30,23,
72 | 24,-41,12,70,-43,
73 | 15,-17,6,13,16,
74 | -13,8,30,-15,-8,
75 | 5,23,-34,-98,-4,
76 | -13,13,-48,-31,70,
77 | 12,31,25,24,-24,
78 | 26,-7,33,-16,8,
79 | 5,-11,-14,-8,-65,
80 | 13,10,-2,-9,0,
81 | -3,-68,5,35,7,
82 | 0,-31,-1,-17,-9,
83 | -9,16,-37,-18,-1,
84 | 69,-48,-28,22,-21,
85 | -11,5,49,55,23,
86 | -86,-36,16,2,13,
87 | 63,-51,30,-11,13,
88 | 24,-18,-6,14,-19,
89 | 1,41,9,-5,27,
90 | -36,-44,-34,-37,-21,
91 | -26,31,-39,15,43,
92 | 5,-8,29,20,-8,
93 | -20,-52,-28,-1,13,
94 | 26,-34,-10,-9,27,
95 | -8,8,27,-66,4,
96 | 12,-22,49,10,-77,
97 | 32,-18,3,-38,12,
98 | -3,-1,2,2,0};
99 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/fftwrap.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2005 Jean-Marc Valin
2 | File: fftwrap.h
3 |
4 | Wrapper for various FFTs
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions
8 | are met:
9 |
10 | - Redistributions of source code must retain the above copyright
11 | notice, this list of conditions and the following disclaimer.
12 |
13 | - Redistributions in binary form must reproduce the above copyright
14 | notice, this list of conditions and the following disclaimer in the
15 | documentation and/or other materials provided with the distribution.
16 |
17 | - Neither the name of the Xiph.org Foundation nor the names of its
18 | contributors may be used to endorse or promote products derived from
19 | this software without specific prior written permission.
20 |
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 |
33 | */
34 |
35 | #ifndef FFTWRAP_H
36 | #define FFTWRAP_H
37 |
38 | #include "arch.h"
39 |
40 | /** Compute tables for an FFT */
41 | void *spx_fft_init(int size);
42 |
43 | /** Destroy tables for an FFT */
44 | void spx_fft_destroy(void *table);
45 |
46 | /** Forward (real to half-complex) transform */
47 | void spx_fft(void *table, spx_word16_t *in, spx_word16_t *out);
48 |
49 | /** Backward (half-complex to real) transform */
50 | void spx_ifft(void *table, spx_word16_t *in, spx_word16_t *out);
51 |
52 | /** Forward (real to half-complex) transform of float data */
53 | void spx_fft_float(void *table, float *in, float *out);
54 |
55 | /** Backward (half-complex to real) transform of float data */
56 | void spx_ifft_float(void *table, float *in, float *out);
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/filters.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2002 Jean-Marc Valin */
2 | /**
3 | @file filters.h
4 | @brief Various analysis/synthesis filters
5 | */
6 | /*
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | - Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 |
14 | - Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions and the following disclaimer in the
16 | documentation and/or other materials provided with the distribution.
17 |
18 | - Neither the name of the Xiph.org Foundation nor the names of its
19 | contributors may be used to endorse or promote products derived from
20 | this software without specific prior written permission.
21 |
22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef FILTERS_H
36 | #define FILTERS_H
37 |
38 | #include "arch.h"
39 |
40 | spx_word16_t compute_rms(const spx_sig_t *x, int len);
41 | spx_word16_t compute_rms16(const spx_word16_t *x, int len);
42 | void signal_mul(const spx_sig_t *x, spx_sig_t *y, spx_word32_t scale, int len);
43 | void signal_div(const spx_word16_t *x, spx_word16_t *y, spx_word32_t scale, int len);
44 |
45 | #ifdef FIXED_POINT
46 |
47 | int normalize16(const spx_sig_t *x, spx_word16_t *y, spx_sig_t max_scale, int len);
48 |
49 | #endif
50 |
51 |
52 | #define HIGHPASS_NARROWBAND 0
53 | #define HIGHPASS_WIDEBAND 2
54 | #define HIGHPASS_INPUT 0
55 | #define HIGHPASS_OUTPUT 1
56 | #define HIGHPASS_IRS 4
57 |
58 | void highpass(const spx_word16_t *x, spx_word16_t *y, int len, int filtID, spx_mem_t *mem);
59 |
60 |
61 | void qmf_decomp(const spx_word16_t *xx, const spx_word16_t *aa, spx_word16_t *, spx_word16_t *y2, int N, int M, spx_word16_t *mem, char *stack);
62 | void qmf_synth(const spx_word16_t *x1, const spx_word16_t *x2, const spx_word16_t *a, spx_word16_t *y, int N, int M, spx_word16_t *mem1, spx_word16_t *mem2, char *stack);
63 |
64 | void filter_mem16(const spx_word16_t *x, const spx_coef_t *num, const spx_coef_t *den, spx_word16_t *y, int N, int ord, spx_mem_t *mem, char *stack);
65 |
66 | #ifdef MERGE_FILTERS
67 |
68 | #define OVERRIDE_IIR_MEM16
69 | #define OVERRIDE_FIR_MEM16
70 | extern const spx_word16_t zeros[];
71 | #define iir_mem16(x, den, y, N, ord, mem, stack) filter_mem16(x, zeros, den, y, N, ord, mem, stack)
72 | #define fir_mem16(x, num, y, N, ord, mem, stack) filter_mem16(x, num, zeros, y, N, ord, mem, stack)
73 |
74 | #else /* MERGE_FILTERS */
75 | void iir_mem16(const spx_word16_t *x, const spx_coef_t *den, spx_word16_t *y, int N, int ord, spx_mem_t *mem, char *stack);
76 | void fir_mem16(const spx_word16_t *x, const spx_coef_t *num, spx_word16_t *y, int N, int ord, spx_mem_t *mem, char *stack);
77 | #endif /* MERGE_FILTERS */
78 |
79 | /* Apply bandwidth expansion on LPC coef */
80 | void bw_lpc(spx_word16_t , const spx_coef_t *lpc_in, spx_coef_t *lpc_out, int order);
81 | void sanitize_values32(spx_word32_t *vec, spx_word32_t min_val, spx_word32_t max_val, int len);
82 |
83 |
84 | void syn_percep_zero16(const spx_word16_t *xx, const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_word16_t *y, int N, int ord, char *stack);
85 | void residue_percep_zero16(const spx_word16_t *xx, const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_word16_t *y, int N, int ord, char *stack);
86 |
87 | void compute_impulse_response(const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_word16_t *y, int N, int ord, char *stack);
88 |
89 | void multicomb(
90 | spx_word16_t *exc, /*decoded excitation*/
91 | spx_word16_t *new_exc, /*enhanced excitation*/
92 | spx_coef_t *ak, /*LPC filter coefs*/
93 | int p, /*LPC order*/
94 | int nsf, /*sub-frame size*/
95 | int pitch, /*pitch period*/
96 | int max_pitch, /*pitch gain (3-tap)*/
97 | spx_word16_t comb_gain, /*gain of comb filter*/
98 | char *stack
99 | );
100 |
101 |
102 | #define filter10(x, num, den, y, N, mem, stack) filter_mem16(x, num, den, y, N, 10, mem, stack)
103 |
104 |
105 | #endif
106 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/filters_arm4.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2004 Jean-Marc Valin */
2 | /**
3 | @file filters_arm4.h
4 | @brief Various analysis/synthesis filters (ARM4 version)
5 | */
6 | /*
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | - Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 |
14 | - Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions and the following disclaimer in the
16 | documentation and/or other materials provided with the distribution.
17 |
18 | - Neither the name of the Xiph.org Foundation nor the names of its
19 | contributors may be used to endorse or promote products derived from
20 | this software without specific prior written permission.
21 |
22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #define OVERRIDE_NORMALIZE16
36 | int normalize16(const spx_sig_t *x, spx_word16_t *y, spx_sig_t max_scale, int len)
37 | {
38 | spx_sig_t max_val=1;
39 | int sig_shift;
40 | int dead1, dead2, dead3, dead4, dead5, dead6;
41 |
42 | __asm__ __volatile__ (
43 | "\tmov %1, #1 \n"
44 | "\tmov %3, #0 \n"
45 |
46 | ".normalize16loop1%=: \n"
47 |
48 | "\tldr %4, [%0], #4 \n"
49 | "\tcmp %4, %1 \n"
50 | "\tmovgt %1, %4 \n"
51 | "\tcmp %4, %3 \n"
52 | "\tmovlt %3, %4 \n"
53 |
54 | "\tsubs %2, %2, #1 \n"
55 | "\tbne .normalize16loop1%=\n"
56 |
57 | "\trsb %3, %3, #0 \n"
58 | "\tcmp %1, %3 \n"
59 | "\tmovlt %1, %3 \n"
60 | : "=r" (dead1), "=r" (max_val), "=r" (dead3), "=r" (dead4),
61 | "=r" (dead5), "=r" (dead6)
62 | : "0" (x), "2" (len)
63 | : "cc");
64 |
65 | sig_shift=0;
66 | while (max_val>max_scale)
67 | {
68 | sig_shift++;
69 | max_val >>= 1;
70 | }
71 |
72 | __asm__ __volatile__ (
73 | ".normalize16loop%=: \n"
74 |
75 | "\tldr %4, [%0], #4 \n"
76 | "\tldr %5, [%0], #4 \n"
77 | "\tmov %4, %4, asr %3 \n"
78 | "\tstrh %4, [%1], #2 \n"
79 | "\tldr %4, [%0], #4 \n"
80 | "\tmov %5, %5, asr %3 \n"
81 | "\tstrh %5, [%1], #2 \n"
82 | "\tldr %5, [%0], #4 \n"
83 | "\tmov %4, %4, asr %3 \n"
84 | "\tstrh %4, [%1], #2 \n"
85 | "\tsubs %2, %2, #1 \n"
86 | "\tmov %5, %5, asr %3 \n"
87 | "\tstrh %5, [%1], #2 \n"
88 |
89 | "\tbgt .normalize16loop%=\n"
90 | : "=r" (dead1), "=r" (dead2), "=r" (dead3), "=r" (dead4),
91 | "=r" (dead5), "=r" (dead6)
92 | : "0" (x), "1" (y), "2" (len>>2), "3" (sig_shift)
93 | : "cc", "memory");
94 | return sig_shift;
95 | }
96 |
97 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/fixed_arm4.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2004 Jean-Marc Valin */
2 | /**
3 | @file fixed_arm4.h
4 | @brief ARM4 fixed-point operations
5 | */
6 | /*
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | - Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 |
14 | - Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions and the following disclaimer in the
16 | documentation and/or other materials provided with the distribution.
17 |
18 | - Neither the name of the Xiph.org Foundation nor the names of its
19 | contributors may be used to endorse or promote products derived from
20 | this software without specific prior written permission.
21 |
22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef FIXED_ARM4_H
36 | #define FIXED_ARM4_H
37 |
38 | #undef MULT16_32_Q14
39 | static inline spx_word32_t MULT16_32_Q14(spx_word16_t x, spx_word32_t y) {
40 | int res;
41 | int dummy;
42 | asm (
43 | "smull %0,%1,%2,%3 \n\t"
44 | "mov %0, %0, lsr #14 \n\t"
45 | "add %0, %0, %1, lsl #18 \n\t"
46 | : "=&r"(res), "=&r" (dummy)
47 | : "r"(y),"r"((int)x));
48 | return(res);
49 | }
50 |
51 | #undef MULT16_32_Q15
52 | static inline spx_word32_t MULT16_32_Q15(spx_word16_t x, spx_word32_t y) {
53 | int res;
54 | int dummy;
55 | asm (
56 | "smull %0,%1,%2,%3 \n\t"
57 | "mov %0, %0, lsr #15 \n\t"
58 | "add %0, %0, %1, lsl #17 \n\t"
59 | : "=&r"(res), "=&r" (dummy)
60 | : "r"(y),"r"((int)x));
61 | return(res);
62 | }
63 |
64 | #undef DIV32_16
65 | static inline short DIV32_16(int a, int b)
66 | {
67 | int res=0;
68 | int dead1, dead2, dead3, dead4, dead5;
69 | __asm__ __volatile__ (
70 | "\teor %5, %0, %1\n"
71 | "\tmovs %4, %0\n"
72 | "\trsbmi %0, %0, #0 \n"
73 | "\tmovs %4, %1\n"
74 | "\trsbmi %1, %1, #0 \n"
75 | "\tmov %4, #1\n"
76 |
77 | "\tsubs %3, %0, %1, asl #14 \n"
78 | "\tmovpl %0, %3 \n"
79 | "\torrpl %2, %2, %4, asl #14 \n"
80 |
81 | "\tsubs %3, %0, %1, asl #13 \n"
82 | "\tmovpl %0, %3 \n"
83 | "\torrpl %2, %2, %4, asl #13 \n"
84 |
85 | "\tsubs %3, %0, %1, asl #12 \n"
86 | "\tmovpl %0, %3 \n"
87 | "\torrpl %2, %2, %4, asl #12 \n"
88 |
89 | "\tsubs %3, %0, %1, asl #11 \n"
90 | "\tmovpl %0, %3 \n"
91 | "\torrpl %2, %2, %4, asl #11 \n"
92 |
93 | "\tsubs %3, %0, %1, asl #10 \n"
94 | "\tmovpl %0, %3 \n"
95 | "\torrpl %2, %2, %4, asl #10 \n"
96 |
97 | "\tsubs %3, %0, %1, asl #9 \n"
98 | "\tmovpl %0, %3 \n"
99 | "\torrpl %2, %2, %4, asl #9 \n"
100 |
101 | "\tsubs %3, %0, %1, asl #8 \n"
102 | "\tmovpl %0, %3 \n"
103 | "\torrpl %2, %2, %4, asl #8 \n"
104 |
105 | "\tsubs %3, %0, %1, asl #7 \n"
106 | "\tmovpl %0, %3 \n"
107 | "\torrpl %2, %2, %4, asl #7 \n"
108 |
109 | "\tsubs %3, %0, %1, asl #6 \n"
110 | "\tmovpl %0, %3 \n"
111 | "\torrpl %2, %2, %4, asl #6 \n"
112 |
113 | "\tsubs %3, %0, %1, asl #5 \n"
114 | "\tmovpl %0, %3 \n"
115 | "\torrpl %2, %2, %4, asl #5 \n"
116 |
117 | "\tsubs %3, %0, %1, asl #4 \n"
118 | "\tmovpl %0, %3 \n"
119 | "\torrpl %2, %2, %4, asl #4 \n"
120 |
121 | "\tsubs %3, %0, %1, asl #3 \n"
122 | "\tmovpl %0, %3 \n"
123 | "\torrpl %2, %2, %4, asl #3 \n"
124 |
125 | "\tsubs %3, %0, %1, asl #2 \n"
126 | "\tmovpl %0, %3 \n"
127 | "\torrpl %2, %2, %4, asl #2 \n"
128 |
129 | "\tsubs %3, %0, %1, asl #1 \n"
130 | "\tmovpl %0, %3 \n"
131 | "\torrpl %2, %2, %4, asl #1 \n"
132 |
133 | "\tsubs %3, %0, %1 \n"
134 | "\tmovpl %0, %3 \n"
135 | "\torrpl %2, %2, %4 \n"
136 |
137 | "\tmovs %5, %5, lsr #31 \n"
138 | "\trsbne %2, %2, #0 \n"
139 | : "=r" (dead1), "=r" (dead2), "=r" (res),
140 | "=r" (dead3), "=r" (dead4), "=r" (dead5)
141 | : "0" (a), "1" (b), "2" (res)
142 | : "cc"
143 | );
144 | return res;
145 | }
146 |
147 |
148 | #endif
149 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/fixed_bfin.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2005 Analog Devices
2 | Author: Jean-Marc Valin */
3 | /**
4 | @file fixed_bfin.h
5 | @brief Blackfin fixed-point operations
6 | */
7 | /*
8 | Redistribution and use in source and binary forms, with or without
9 | modification, are permitted provided that the following conditions
10 | are met:
11 |
12 | - Redistributions of source code must retain the above copyright
13 | notice, this list of conditions and the following disclaimer.
14 |
15 | - Redistributions in binary form must reproduce the above copyright
16 | notice, this list of conditions and the following disclaimer in the
17 | documentation and/or other materials provided with the distribution.
18 |
19 | - Neither the name of the Xiph.org Foundation nor the names of its
20 | contributors may be used to endorse or promote products derived from
21 | this software without specific prior written permission.
22 |
23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
27 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 | */
35 |
36 | #ifndef FIXED_BFIN_H
37 | #define FIXED_BFIN_H
38 |
39 | #include "bfin.h"
40 |
41 | #undef PDIV32_16
42 | static inline spx_word16_t PDIV32_16(spx_word32_t a, spx_word16_t b)
43 | {
44 | spx_word32_t res, bb;
45 | bb = b;
46 | a += b>>1;
47 | __asm__ (
48 | "P0 = 15;\n\t"
49 | "R0 = %1;\n\t"
50 | "R1 = %2;\n\t"
51 | //"R0 = R0 + R1;\n\t"
52 | "R0 <<= 1;\n\t"
53 | "DIVS (R0, R1);\n\t"
54 | "LOOP divide%= LC0 = P0;\n\t"
55 | "LOOP_BEGIN divide%=;\n\t"
56 | "DIVQ (R0, R1);\n\t"
57 | "LOOP_END divide%=;\n\t"
58 | "R0 = R0.L;\n\t"
59 | "%0 = R0;\n\t"
60 | : "=m" (res)
61 | : "m" (a), "m" (bb)
62 | : "P0", "R0", "R1", "ASTAT" BFIN_HWLOOP0_REGS);
63 | return res;
64 | }
65 |
66 | #undef DIV32_16
67 | static inline spx_word16_t DIV32_16(spx_word32_t a, spx_word16_t b)
68 | {
69 | spx_word32_t res, bb;
70 | bb = b;
71 | /* Make the roundinf consistent with the C version
72 | (do we need to do that?)*/
73 | if (a<0)
74 | a += (b-1);
75 | __asm__ (
76 | "P0 = 15;\n\t"
77 | "R0 = %1;\n\t"
78 | "R1 = %2;\n\t"
79 | "R0 <<= 1;\n\t"
80 | "DIVS (R0, R1);\n\t"
81 | "LOOP divide%= LC0 = P0;\n\t"
82 | "LOOP_BEGIN divide%=;\n\t"
83 | "DIVQ (R0, R1);\n\t"
84 | "LOOP_END divide%=;\n\t"
85 | "R0 = R0.L;\n\t"
86 | "%0 = R0;\n\t"
87 | : "=m" (res)
88 | : "m" (a), "m" (bb)
89 | : "P0", "R0", "R1", "ASTAT" BFIN_HWLOOP0_REGS);
90 | return res;
91 | }
92 |
93 | #undef MAX16
94 | static inline spx_word16_t MAX16(spx_word16_t a, spx_word16_t b)
95 | {
96 | spx_word32_t res;
97 | __asm__ (
98 | "%1 = %1.L (X);\n\t"
99 | "%2 = %2.L (X);\n\t"
100 | "%0 = MAX(%1,%2);"
101 | : "=d" (res)
102 | : "%d" (a), "d" (b)
103 | : "ASTAT"
104 | );
105 | return res;
106 | }
107 |
108 | #undef MULT16_32_Q15
109 | static inline spx_word32_t MULT16_32_Q15(spx_word16_t a, spx_word32_t b)
110 | {
111 | spx_word32_t res;
112 | __asm__
113 | (
114 | "A1 = %2.L*%1.L (M);\n\t"
115 | "A1 = A1 >>> 15;\n\t"
116 | "%0 = (A1 += %2.L*%1.H) ;\n\t"
117 | : "=&W" (res), "=&d" (b)
118 | : "d" (a), "1" (b)
119 | : "A1", "ASTAT"
120 | );
121 | return res;
122 | }
123 |
124 | #undef MAC16_32_Q15
125 | static inline spx_word32_t MAC16_32_Q15(spx_word32_t c, spx_word16_t a, spx_word32_t b)
126 | {
127 | spx_word32_t res;
128 | __asm__
129 | (
130 | "A1 = %2.L*%1.L (M);\n\t"
131 | "A1 = A1 >>> 15;\n\t"
132 | "%0 = (A1 += %2.L*%1.H);\n\t"
133 | "%0 = %0 + %4;\n\t"
134 | : "=&W" (res), "=&d" (b)
135 | : "d" (a), "1" (b), "d" (c)
136 | : "A1", "ASTAT"
137 | );
138 | return res;
139 | }
140 |
141 | #undef MULT16_32_Q14
142 | static inline spx_word32_t MULT16_32_Q14(spx_word16_t a, spx_word32_t b)
143 | {
144 | spx_word32_t res;
145 | __asm__
146 | (
147 | "%2 <<= 1;\n\t"
148 | "A1 = %1.L*%2.L (M);\n\t"
149 | "A1 = A1 >>> 15;\n\t"
150 | "%0 = (A1 += %1.L*%2.H);\n\t"
151 | : "=W" (res), "=d" (a), "=d" (b)
152 | : "1" (a), "2" (b)
153 | : "A1", "ASTAT"
154 | );
155 | return res;
156 | }
157 |
158 | #undef MAC16_32_Q14
159 | static inline spx_word32_t MAC16_32_Q14(spx_word32_t c, spx_word16_t a, spx_word32_t b)
160 | {
161 | spx_word32_t res;
162 | __asm__
163 | (
164 | "%1 <<= 1;\n\t"
165 | "A1 = %2.L*%1.L (M);\n\t"
166 | "A1 = A1 >>> 15;\n\t"
167 | "%0 = (A1 += %2.L*%1.H);\n\t"
168 | "%0 = %0 + %4;\n\t"
169 | : "=&W" (res), "=&d" (b)
170 | : "d" (a), "1" (b), "d" (c)
171 | : "A1", "ASTAT"
172 | );
173 | return res;
174 | }
175 |
176 | #endif
177 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/fixed_generic.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2003 Jean-Marc Valin */
2 | /**
3 | @file fixed_generic.h
4 | @brief Generic fixed-point operations
5 | */
6 | /*
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | - Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 |
14 | - Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions and the following disclaimer in the
16 | documentation and/or other materials provided with the distribution.
17 |
18 | - Neither the name of the Xiph.org Foundation nor the names of its
19 | contributors may be used to endorse or promote products derived from
20 | this software without specific prior written permission.
21 |
22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef FIXED_GENERIC_H
36 | #define FIXED_GENERIC_H
37 |
38 | #define QCONST16(x,bits) ((spx_word16_t)(.5+(x)*(((spx_word32_t)1)<<(bits))))
39 | #define QCONST32(x,bits) ((spx_word32_t)(.5+(x)*(((spx_word32_t)1)<<(bits))))
40 |
41 | #define NEG16(x) (-(x))
42 | #define NEG32(x) (-(x))
43 | #define EXTRACT16(x) ((spx_word16_t)(x))
44 | #define EXTEND32(x) ((spx_word32_t)(x))
45 | #define SHR16(a,shift) ((a) >> (shift))
46 | #define SHL16(a,shift) ((a) << (shift))
47 | #define SHR32(a,shift) ((a) >> (shift))
48 | #define SHL32(a,shift) ((a) << (shift))
49 | #define PSHR16(a,shift) (SHR16((a)+((1<<((shift))>>1)),shift))
50 | #define PSHR32(a,shift) (SHR32((a)+((EXTEND32(1)<<((shift))>>1)),shift))
51 | #define VSHR32(a, shift) (((shift)>0) ? SHR32(a, shift) : SHL32(a, -(shift)))
52 | #define SATURATE16(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
53 | #define SATURATE32(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
54 |
55 | #define SHR(a,shift) ((a) >> (shift))
56 | #define SHL(a,shift) ((spx_word32_t)(a) << (shift))
57 | #define PSHR(a,shift) (SHR((a)+((EXTEND32(1)<<((shift))>>1)),shift))
58 | #define SATURATE(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
59 |
60 |
61 | #define ADD16(a,b) ((spx_word16_t)((spx_word16_t)(a)+(spx_word16_t)(b)))
62 | #define SUB16(a,b) ((spx_word16_t)(a)-(spx_word16_t)(b))
63 | #define ADD32(a,b) ((spx_word32_t)(a)+(spx_word32_t)(b))
64 | #define SUB32(a,b) ((spx_word32_t)(a)-(spx_word32_t)(b))
65 |
66 |
67 | /* result fits in 16 bits */
68 | #define MULT16_16_16(a,b) ((((spx_word16_t)(a))*((spx_word16_t)(b))))
69 |
70 | /* (spx_word32_t)(spx_word16_t) gives TI compiler a hint that it's 16x16->32 multiply */
71 | #define MULT16_16(a,b) (((spx_word32_t)(spx_word16_t)(a))*((spx_word32_t)(spx_word16_t)(b)))
72 |
73 | #define MAC16_16(c,a,b) (ADD32((c),MULT16_16((a),(b))))
74 | #define MULT16_32_Q12(a,b) ADD32(MULT16_16((a),SHR((b),12)), SHR(MULT16_16((a),((b)&0x00000fff)),12))
75 | #define MULT16_32_Q13(a,b) ADD32(MULT16_16((a),SHR((b),13)), SHR(MULT16_16((a),((b)&0x00001fff)),13))
76 | #define MULT16_32_Q14(a,b) ADD32(MULT16_16((a),SHR((b),14)), SHR(MULT16_16((a),((b)&0x00003fff)),14))
77 |
78 | #define MULT16_32_Q11(a,b) ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11))
79 | #define MAC16_32_Q11(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11)))
80 |
81 | #define MULT16_32_P15(a,b) ADD32(MULT16_16((a),SHR((b),15)), PSHR(MULT16_16((a),((b)&0x00007fff)),15))
82 | #define MULT16_32_Q15(a,b) ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15))
83 | #define MAC16_32_Q15(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15)))
84 |
85 |
86 | #define MAC16_16_Q11(c,a,b) (ADD32((c),SHR(MULT16_16((a),(b)),11)))
87 | #define MAC16_16_Q13(c,a,b) (ADD32((c),SHR(MULT16_16((a),(b)),13)))
88 | #define MAC16_16_P13(c,a,b) (ADD32((c),SHR(ADD32(4096,MULT16_16((a),(b))),13)))
89 |
90 | #define MULT16_16_Q11_32(a,b) (SHR(MULT16_16((a),(b)),11))
91 | #define MULT16_16_Q13(a,b) (SHR(MULT16_16((a),(b)),13))
92 | #define MULT16_16_Q14(a,b) (SHR(MULT16_16((a),(b)),14))
93 | #define MULT16_16_Q15(a,b) (SHR(MULT16_16((a),(b)),15))
94 |
95 | #define MULT16_16_P13(a,b) (SHR(ADD32(4096,MULT16_16((a),(b))),13))
96 | #define MULT16_16_P14(a,b) (SHR(ADD32(8192,MULT16_16((a),(b))),14))
97 | #define MULT16_16_P15(a,b) (SHR(ADD32(16384,MULT16_16((a),(b))),15))
98 |
99 | #define MUL_16_32_R15(a,bh,bl) ADD32(MULT16_16((a),(bh)), SHR(MULT16_16((a),(bl)),15))
100 |
101 | #define DIV32_16(a,b) ((spx_word16_t)(((spx_word32_t)(a))/((spx_word16_t)(b))))
102 | #define PDIV32_16(a,b) ((spx_word16_t)(((spx_word32_t)(a)+((spx_word16_t)(b)>>1))/((spx_word16_t)(b))))
103 | #define DIV32(a,b) (((spx_word32_t)(a))/((spx_word32_t)(b)))
104 | #define PDIV32(a,b) (((spx_word32_t)(a)+((spx_word16_t)(b)>>1))/((spx_word32_t)(b)))
105 |
106 | #endif
107 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/gain_table.c:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2002 Jean-Marc Valin
2 | File: gain_table.c
3 | Codebook for 3-tap pitch prediction gain (128 entries)
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are
7 | met:
8 |
9 | 1. Redistributions of source code must retain the above copyright notice,
10 | this list of conditions and the following disclaimer.
11 |
12 | 2. Redistributions in binary form must reproduce the above copyright
13 | notice, this list of conditions and the following disclaimer in the
14 | documentation and/or other materials provided with the distribution.
15 |
16 | 3. The name of the author may not be used to endorse or promote products
17 | derived from this software without specific prior written permission.
18 |
19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
23 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 | POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | const signed char gain_cdbk_nb[512] = {
33 | -32, -32, -32, 0,
34 | -28, -67, -5, 33,
35 | -42, -6, -32, 18,
36 | -57, -10, -54, 35,
37 | -16, 27, -41, 42,
38 | 19, -19, -40, 36,
39 | -45, 24, -21, 40,
40 | -8, -14, -18, 28,
41 | 1, 14, -58, 53,
42 | -18, -88, -39, 39,
43 | -38, 21, -18, 37,
44 | -19, 20, -43, 38,
45 | 10, 17, -48, 54,
46 | -52, -58, -13, 33,
47 | -44, -1, -11, 32,
48 | -12, -11, -34, 22,
49 | 14, 0, -46, 46,
50 | -37, -35, -34, 5,
51 | -25, 44, -30, 43,
52 | 6, -4, -63, 49,
53 | -31, 43, -41, 43,
54 | -23, 30, -43, 41,
55 | -43, 26, -14, 44,
56 | -33, 1, -13, 27,
57 | -13, 18, -37, 37,
58 | -46, -73, -45, 34,
59 | -36, 24, -25, 34,
60 | -36, -11, -20, 19,
61 | -25, 12, -18, 33,
62 | -36, -69, -59, 34,
63 | -45, 6, 8, 46,
64 | -22, -14, -24, 18,
65 | -1, 13, -44, 44,
66 | -39, -48, -26, 15,
67 | -32, 31, -37, 34,
68 | -33, 15, -46, 31,
69 | -24, 30, -36, 37,
70 | -41, 31, -23, 41,
71 | -50, 22, -4, 50,
72 | -22, 2, -21, 28,
73 | -17, 30, -34, 40,
74 | -7, -60, -28, 29,
75 | -38, 42, -28, 42,
76 | -44, -11, 21, 43,
77 | -16, 8, -44, 34,
78 | -39, -55, -43, 21,
79 | -11, -35, 26, 41,
80 | -9, 0, -34, 29,
81 | -8, 121, -81, 113,
82 | 7, -16, -22, 33,
83 | -37, 33, -31, 36,
84 | -27, -7, -36, 17,
85 | -34, 70, -57, 65,
86 | -37, -11, -48, 21,
87 | -40, 17, -1, 44,
88 | -33, 6, -6, 33,
89 | -9, 0, -20, 34,
90 | -21, 69, -33, 57,
91 | -29, 33, -31, 35,
92 | -55, 12, -1, 49,
93 | -33, 27, -22, 35,
94 | -50, -33, -47, 17,
95 | -50, 54, 51, 94,
96 | -1, -5, -44, 35,
97 | -4, 22, -40, 45,
98 | -39, -66, -25, 24,
99 | -33, 1, -26, 20,
100 | -24, -23, -25, 12,
101 | -11, 21, -45, 44,
102 | -25, -45, -19, 17,
103 | -43, 105, -16, 82,
104 | 5, -21, 1, 41,
105 | -16, 11, -33, 30,
106 | -13, -99, -4, 57,
107 | -37, 33, -15, 44,
108 | -25, 37, -63, 54,
109 | -36, 24, -31, 31,
110 | -53, -56, -38, 26,
111 | -41, -4, 4, 37,
112 | -33, 13, -30, 24,
113 | 49, 52, -94, 114,
114 | -5, -30, -15, 23,
115 | 1, 38, -40, 56,
116 | -23, 12, -36, 29,
117 | -17, 40, -47, 51,
118 | -37, -41, -39, 11,
119 | -49, 34, 0, 58,
120 | -18, -7, -4, 34,
121 | -16, 17, -27, 35,
122 | 30, 5, -62, 65,
123 | 4, 48, -68, 76,
124 | -43, 11, -11, 38,
125 | -18, 19, -15, 41,
126 | -23, -62, -39, 23,
127 | -42, 10, -2, 41,
128 | -21, -13, -13, 25,
129 | -9, 13, -47, 42,
130 | -23, -62, -24, 24,
131 | -44, 60, -21, 58,
132 | -18, -3, -52, 32,
133 | -22, 22, -36, 34,
134 | -75, 57, 16, 90,
135 | -19, 3, 10, 45,
136 | -29, 23, -38, 32,
137 | -5, -62, -51, 38,
138 | -51, 40, -18, 53,
139 | -42, 13, -24, 32,
140 | -34, 14, -20, 30,
141 | -56, -75, -26, 37,
142 | -26, 32, 15, 59,
143 | -26, 17, -29, 29,
144 | -7, 28, -52, 53,
145 | -12, -30, 5, 30,
146 | -5, -48, -5, 35,
147 | 2, 2, -43, 40,
148 | 21, 16, 16, 75,
149 | -25, -45, -32, 10,
150 | -43, 18, -10, 42,
151 | 9, 0, -1, 52,
152 | -1, 7, -30, 36,
153 | 19, -48, -4, 48,
154 | -28, 25, -29, 32,
155 | -22, 0, -31, 22,
156 | -32, 17, -10, 36,
157 | -64, -41, -62, 36,
158 | -52, 15, 16, 58,
159 | -30, -22, -32, 6,
160 | -7, 9, -38, 36};
161 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/gain_table_lbr.c:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2002 Jean-Marc Valin
2 | File: gain_table_lbr.c
3 | Codebook for 3-tap pitch prediction gain (32 entries)
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are
7 | met:
8 |
9 | 1. Redistributions of source code must retain the above copyright notice,
10 | this list of conditions and the following disclaimer.
11 |
12 | 2. Redistributions in binary form must reproduce the above copyright
13 | notice, this list of conditions and the following disclaimer in the
14 | documentation and/or other materials provided with the distribution.
15 |
16 | 3. The name of the author may not be used to endorse or promote products
17 | derived from this software without specific prior written permission.
18 |
19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
23 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 | POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | const signed char gain_cdbk_lbr[128] = {
33 | -32, -32, -32, 0,
34 | -31, -58, -16, 22,
35 | -41, -24, -43, 14,
36 | -56, -22, -55, 29,
37 | -13, 33, -41, 47,
38 | -4, -39, -9, 29,
39 | -41, 15, -12, 38,
40 | -8, -15, -12, 31,
41 | 1, 2, -44, 40,
42 | -22, -66, -42, 27,
43 | -38, 28, -23, 38,
44 | -21, 14, -37, 31,
45 | 0, 21, -50, 52,
46 | -53, -71, -27, 33,
47 | -37, -1, -19, 25,
48 | -19, -5, -28, 22,
49 | 6, 65, -44, 74,
50 | -33, -48, -33, 9,
51 | -40, 57, -14, 58,
52 | -17, 4, -45, 32,
53 | -31, 38, -33, 36,
54 | -23, 28, -40, 39,
55 | -43, 29, -12, 46,
56 | -34, 13, -23, 28,
57 | -16, 15, -27, 34,
58 | -14, -82, -15, 43,
59 | -31, 25, -32, 29,
60 | -21, 5, -5, 38,
61 | -47, -63, -51, 33,
62 | -46, 12, 3, 47,
63 | -28, -17, -29, 11,
64 | -10, 14, -40, 38};
65 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/hexc_10_32_table.c:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2002 Jean-Marc Valin
2 | File: hexc_10_32_table.c
3 | Codebook for high-band excitation in SB-CELP mode (4000 bps)
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions
7 | are met:
8 |
9 | - Redistributions of source code must retain the above copyright
10 | notice, this list of conditions and the following disclaimer.
11 |
12 | - Redistributions in binary form must reproduce the above copyright
13 | notice, this list of conditions and the following disclaimer in the
14 | documentation and/or other materials provided with the distribution.
15 |
16 | - Neither the name of the Xiph.org Foundation nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
24 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 | */
32 |
33 | const signed char hexc_10_32_table[320] = {
34 | -3, -2, -1, 0, -4, 5, 35, -40, -9, 13,
35 | -44, 5, -27, -1, -7, 6, -11, 7, -8, 7,
36 | 19, -14, 15, -4, 9, -10, 10, -8, 10, -9,
37 | -1, 1, 0, 0, 2, 5, -18, 22, -53, 50,
38 | 1, -23, 50, -36, 15, 3, -13, 14, -10, 6,
39 | 1, 5, -3, 4, -2, 5, -32, 25, 5, -2,
40 | -1, -4, 1, 11, -29, 26, -6, -15, 30, -18,
41 | 0, 15, -17, 40, -41, 3, 9, -2, -2, 3,
42 | -3, -1, -5, 2, 21, -6, -16, -21, 23, 2,
43 | 60, 15, 16, -16, -9, 14, 9, -1, 7, -9,
44 | 0, 1, 1, 0, -1, -6, 17, -28, 54, -45,
45 | -1, 1, -1, -6, -6, 2, 11, 26, -29, -2,
46 | 46, -21, 34, 12, -23, 32, -23, 16, -10, 3,
47 | 66, 19, -20, 24, 7, 11, -3, 0, -3, -1,
48 | -50, -46, 2, -18, -3, 4, -1, -2, 3, -3,
49 | -19, 41, -36, 9, 11, -24, 21, -16, 9, -3,
50 | -25, -3, 10, 18, -9, -2, -5, -1, -5, 6,
51 | -4, -3, 2, -26, 21, -19, 35, -15, 7, -13,
52 | 17, -19, 39, -43, 48, -31, 16, -9, 7, -2,
53 | -5, 3, -4, 9, -19, 27, -55, 63, -35, 10,
54 | 26, -44, -2, 9, 4, 1, -6, 8, -9, 5,
55 | -8, -1, -3, -16, 45, -42, 5, 15, -16, 10,
56 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
57 | -16, 24, -55, 47, -38, 27, -19, 7, -3, 1,
58 | 16, 27, 20, -19, 18, 5, -7, 1, -5, 2,
59 | -6, 8, -22, 0, -3, -3, 8, -1, 7, -8,
60 | 1, -3, 5, 0, 17, -48, 58, -52, 29, -7,
61 | -2, 3, -10, 6, -26, 58, -31, 1, -6, 3,
62 | 93, -29, 39, 3, 17, 5, 6, -1, -1, -1,
63 | 27, 13, 10, 19, -7, -34, 12, 10, -4, 9,
64 | -76, 9, 8, -28, -2, -11, 2, -1, 3, 1,
65 | -83, 38, -39, 4, -16, -6, -2, -5, 5, -2,
66 | };
67 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/kiss_fft.h:
--------------------------------------------------------------------------------
1 | #ifndef KISS_FFT_H
2 | #define KISS_FFT_H
3 |
4 | #include
5 | #include
6 | #include "arch.h"
7 |
8 | #ifdef __cplusplus
9 | extern "C" {
10 | #endif
11 |
12 | /*
13 | ATTENTION!
14 | If you would like a :
15 | -- a utility that will handle the caching of fft objects
16 | -- real-only (no imaginary time component ) FFT
17 | -- a multi-dimensional FFT
18 | -- a command-line utility to perform ffts
19 | -- a command-line utility to perform fast-convolution filtering
20 |
21 | Then see kfc.h kiss_fftr.h kiss_fftnd.h fftutil.c kiss_fastfir.c
22 | in the tools/ directory.
23 | */
24 |
25 | #ifdef USE_SIMD
26 | # include
27 | # define kiss_fft_scalar __m128
28 | #define KISS_FFT_MALLOC(nbytes) memalign(16,nbytes)
29 | #else
30 | #define KISS_FFT_MALLOC speex_alloc
31 | #endif
32 |
33 |
34 | #ifdef FIXED_POINT
35 | #include "arch.h"
36 | # define kiss_fft_scalar spx_int16_t
37 | #else
38 | # ifndef kiss_fft_scalar
39 | /* default is float */
40 | # define kiss_fft_scalar float
41 | # endif
42 | #endif
43 |
44 | typedef struct {
45 | kiss_fft_scalar r;
46 | kiss_fft_scalar i;
47 | }kiss_fft_cpx;
48 |
49 | typedef struct kiss_fft_state* kiss_fft_cfg;
50 |
51 | /*
52 | * kiss_fft_alloc
53 | *
54 | * Initialize a FFT (or IFFT) algorithm's cfg/state buffer.
55 | *
56 | * typical usage: kiss_fft_cfg mycfg=kiss_fft_alloc(1024,0,NULL,NULL);
57 | *
58 | * The return value from fft_alloc is a cfg buffer used internally
59 | * by the fft routine or NULL.
60 | *
61 | * If lenmem is NULL, then kiss_fft_alloc will allocate a cfg buffer using malloc.
62 | * The returned value should be free()d when done to avoid memory leaks.
63 | *
64 | * The state can be placed in a user supplied buffer 'mem':
65 | * If lenmem is not NULL and mem is not NULL and *lenmem is large enough,
66 | * then the function places the cfg in mem and the size used in *lenmem
67 | * and returns mem.
68 | *
69 | * If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough),
70 | * then the function returns NULL and places the minimum cfg
71 | * buffer size in *lenmem.
72 | * */
73 |
74 | kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem);
75 |
76 | /*
77 | * kiss_fft(cfg,in_out_buf)
78 | *
79 | * Perform an FFT on a complex input buffer.
80 | * for a forward FFT,
81 | * fin should be f[0] , f[1] , ... ,f[nfft-1]
82 | * fout will be F[0] , F[1] , ... ,F[nfft-1]
83 | * Note that each element is complex and can be accessed like
84 | f[k].r and f[k].i
85 | * */
86 | void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout);
87 |
88 | /*
89 | A more generic version of the above function. It reads its input from every Nth sample.
90 | * */
91 | void kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int fin_stride);
92 |
93 | /* If kiss_fft_alloc allocated a buffer, it is one contiguous
94 | buffer and can be simply free()d when no longer needed*/
95 | #define kiss_fft_free speex_free
96 |
97 | /*
98 | Cleans up some memory that gets managed internally. Not necessary to call, but it might clean up
99 | your compiler output to call this before you exit.
100 | */
101 | void kiss_fft_cleanup(void);
102 |
103 |
104 | #ifdef __cplusplus
105 | }
106 | #endif
107 |
108 | #endif
109 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/kiss_fftr.h:
--------------------------------------------------------------------------------
1 | #ifndef KISS_FTR_H
2 | #define KISS_FTR_H
3 |
4 | #include "kiss_fft.h"
5 | #ifdef __cplusplus
6 | extern "C" {
7 | #endif
8 |
9 |
10 | /*
11 |
12 | Real optimized version can save about 45% cpu time vs. complex fft of a real seq.
13 |
14 |
15 |
16 | */
17 |
18 | typedef struct kiss_fftr_state *kiss_fftr_cfg;
19 |
20 |
21 | kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem, size_t * lenmem);
22 | /*
23 | nfft must be even
24 |
25 | If you don't care to allocate space, use mem = lenmem = NULL
26 | */
27 |
28 |
29 | void kiss_fftr(kiss_fftr_cfg cfg,const kiss_fft_scalar *timedata,kiss_fft_cpx *freqdata);
30 | /*
31 | input timedata has nfft scalar points
32 | output freqdata has nfft/2+1 complex points
33 | */
34 |
35 | void kiss_fftr2(kiss_fftr_cfg st,const kiss_fft_scalar *timedata,kiss_fft_scalar *freqdata);
36 |
37 | void kiss_fftri(kiss_fftr_cfg cfg,const kiss_fft_cpx *freqdata,kiss_fft_scalar *timedata);
38 |
39 | void kiss_fftri2(kiss_fftr_cfg st,const kiss_fft_scalar *freqdata, kiss_fft_scalar *timedata);
40 |
41 | /*
42 | input freqdata has nfft/2+1 complex points
43 | output timedata has nfft scalar points
44 | */
45 |
46 | #define kiss_fftr_free speex_free
47 |
48 | #ifdef __cplusplus
49 | }
50 | #endif
51 | #endif
52 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/lpc.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2002 Jean-Marc Valin */
2 | /**
3 | @file lpc.h
4 | @brief Functions for LPC (Linear Prediction Coefficients) analysis
5 | */
6 | /*
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | - Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 |
14 | - Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions and the following disclaimer in the
16 | documentation and/or other materials provided with the distribution.
17 |
18 | - Neither the name of the Xiph.org Foundation nor the names of its
19 | contributors may be used to endorse or promote products derived from
20 | this software without specific prior written permission.
21 |
22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef LPC_H
36 | #define LPC_H
37 |
38 | #include "arch.h"
39 |
40 | void _spx_autocorr(
41 | const spx_word16_t * x, /* in: [0...n-1] samples x */
42 | spx_word16_t *ac, /* out: [0...lag-1] ac values */
43 | int lag, int n);
44 |
45 | spx_word32_t /* returns minimum mean square error */
46 | _spx_lpc(
47 | spx_coef_t * lpc, /* [0...p-1] LPC coefficients */
48 | const spx_word16_t * ac, /* in: [0...p] autocorrelation values */
49 | int p
50 | );
51 |
52 |
53 | #endif
54 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/lpc_bfin.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2005 Analog Devices */
2 | /**
3 | @file lpc_bfin.h
4 | @author Jean-Marc Valin
5 | @brief Functions for LPC (Linear Prediction Coefficients) analysis (Blackfin version)
6 | */
7 | /*
8 | Redistribution and use in source and binary forms, with or without
9 | modification, are permitted provided that the following conditions
10 | are met:
11 |
12 | - Redistributions of source code must retain the above copyright
13 | notice, this list of conditions and the following disclaimer.
14 |
15 | - Redistributions in binary form must reproduce the above copyright
16 | notice, this list of conditions and the following disclaimer in the
17 | documentation and/or other materials provided with the distribution.
18 |
19 | - Neither the name of the Xiph.org Foundation nor the names of its
20 | contributors may be used to endorse or promote products derived from
21 | this software without specific prior written permission.
22 |
23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
27 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 | */
35 |
36 | #include "bfin.h"
37 |
38 | #define OVERRIDE_SPEEX_AUTOCORR
39 | void _spx_autocorr(
40 | const spx_word16_t *x, /* in: [0...n-1] samples x */
41 | spx_word16_t *ac, /* out: [0...lag-1] ac values */
42 | int lag,
43 | int n
44 | )
45 | {
46 | spx_word32_t d;
47 | const spx_word16_t *xs;
48 | int i, j;
49 | spx_word32_t ac0=1;
50 | spx_word32_t ac32[11], *ac32top;
51 | int shift, ac_shift;
52 | ac32top = ac32+lag-1;
53 | int lag_1, N_lag;
54 | int nshift;
55 | lag_1 = lag-1;
56 | N_lag = n-lag_1;
57 | for (j=0;j> 1;\n\t"
94 | "LOOP_BEGIN pitch%=;\n\t"
95 | "I1 = P0;\n\t"
96 | "A1 = A0 = 0;\n\t"
97 | "R1 = [I1++];\n\t"
98 | "LOOP inner_prod%= LC1 = P3 >> 1;\n\t"
99 | "LOOP_BEGIN inner_prod%=;\n\t"
100 | "A1 += R0.L*R1.H, A0 += R0.L*R1.L (IS) || R1.L = W[I1++];\n\t"
101 | "A1 += R0.H*R1.L, A0 += R0.H*R1.H (IS) || R1.H = W[I1++] || R0 = [I0++];\n\t"
102 | "LOOP_END inner_prod%=;\n\t"
103 | "A0 = ASHIFT A0 by R4.L;\n\t"
104 | "A1 = ASHIFT A1 by R4.L;\n\t"
105 |
106 | "R2 = A0, R3 = A1;\n\t"
107 | "[P1--] = R2;\n\t"
108 | "[P1--] = R3;\n\t"
109 | "P0 += 4;\n\t"
110 | "LOOP_END pitch%=;\n\t"
111 | : : "m" (xs), "m" (x), "m" (ac32top), "m" (N_lag), "m" (lag_1), "m" (nshift)
112 | : "A0", "A1", "P0", "P1", "P2", "P3", "P4", "R0", "R1", "R2", "R3", "R4", "I0", "I1", "L0", "L1", "B0", "B1", "memory",
113 | "ASTAT" BFIN_HWLOOP0_REGS BFIN_HWLOOP1_REGS
114 | );
115 | d=0;
116 | for (j=0;j>>= 14;\n\t"
63 | "R3 = R3 + R5;\n\t"
64 |
65 | "R0 = R2;\n\t" /* R0: b0 */
66 | "R1 = 16384;\n\t" /* R1: b1 */
67 | "LOOP cpe%= LC0 = %3;\n\t"
68 | "LOOP_BEGIN cpe%=;\n\t"
69 | "P1 = R0;\n\t"
70 | "R0 = R2.L * R0.L (IS) || R5 = W[P0--] (X);\n\t"
71 | "R0 >>>= 13;\n\t"
72 | "R0 = R0 - R1;\n\t"
73 | "R1 = P1;\n\t"
74 | "R5 = R5.L * R0.L (IS);\n\t"
75 | "R5 = R5 + R4;\n\t"
76 | "R5 >>>= 14;\n\t"
77 | "R3 = R3 + R5;\n\t"
78 | "LOOP_END cpe%=;\n\t"
79 | "%0 = R3;\n\t"
80 | : "=&d" (sum)
81 | : "a" (x), "a" (&coef[m]), "a" (m-1)
82 | : "R0", "R1", "R3", "R2", "R4", "R5", "P0", "P1", "ASTAT" BFIN_HWLOOP0_REGS
83 | );
84 | return sum;
85 | }
86 | #endif
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/ltp_sse.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2002 Jean-Marc Valin */
2 | /**
3 | @file ltp_sse.h
4 | @brief Long-Term Prediction functions (SSE version)
5 | */
6 | /*
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | - Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 |
14 | - Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions and the following disclaimer in the
16 | documentation and/or other materials provided with the distribution.
17 |
18 | - Neither the name of the Xiph.org Foundation nor the names of its
19 | contributors may be used to endorse or promote products derived from
20 | this software without specific prior written permission.
21 |
22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #include
36 |
37 | #define OVERRIDE_INNER_PROD
38 | float inner_prod(const float *a, const float *b, int len)
39 | {
40 | int i;
41 | float ret;
42 | __m128 sum = _mm_setzero_ps();
43 | for (i=0;i<(len>>2);i+=2)
44 | {
45 | sum = _mm_add_ps(sum, _mm_mul_ps(_mm_loadu_ps(a+0), _mm_loadu_ps(b+0)));
46 | sum = _mm_add_ps(sum, _mm_mul_ps(_mm_loadu_ps(a+4), _mm_loadu_ps(b+4)));
47 | a += 8;
48 | b += 8;
49 | }
50 | sum = _mm_add_ps(sum, _mm_movehl_ps(sum, sum));
51 | sum = _mm_add_ss(sum, _mm_shuffle_ps(sum, sum, 0x55));
52 | _mm_store_ss(&ret, sum);
53 | return ret;
54 | }
55 |
56 | #define OVERRIDE_PITCH_XCORR
57 | void pitch_xcorr(const float *_x, const float *_y, float *corr, int len, int nb_pitch, char *stack)
58 | {
59 | int i, offset;
60 | VARDECL(__m128 *x);
61 | VARDECL(__m128 *y);
62 | int N, L;
63 | N = len>>2;
64 | L = nb_pitch>>2;
65 | ALLOC(x, N, __m128);
66 | ALLOC(y, N+L, __m128);
67 | for (i=0;i>2)-1), "0" (src), "1" (dest)
53 | : "R0", "I0", "L0", "memory" BFIN_HWLOOP0_REGS
54 | );
55 | return dest;
56 | }
57 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/quant_lsp.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2002 Jean-Marc Valin */
2 | /**
3 | @file quant_lsp.h
4 | @brief LSP vector quantization
5 | */
6 | /*
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | - Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 |
14 | - Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions and the following disclaimer in the
16 | documentation and/or other materials provided with the distribution.
17 |
18 | - Neither the name of the Xiph.org Foundation nor the names of its
19 | contributors may be used to endorse or promote products derived from
20 | this software without specific prior written permission.
21 |
22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef QUANT_LSP_H
36 | #define QUANT_LSP_H
37 |
38 | #include "speex/speex_bits.h"
39 | #include "arch.h"
40 |
41 | #define MAX_LSP_SIZE 20
42 |
43 | #define NB_CDBK_SIZE 64
44 | #define NB_CDBK_SIZE_LOW1 64
45 | #define NB_CDBK_SIZE_LOW2 64
46 | #define NB_CDBK_SIZE_HIGH1 64
47 | #define NB_CDBK_SIZE_HIGH2 64
48 |
49 | /*Narrowband codebooks*/
50 | extern const signed char cdbk_nb[];
51 | extern const signed char cdbk_nb_low1[];
52 | extern const signed char cdbk_nb_low2[];
53 | extern const signed char cdbk_nb_high1[];
54 | extern const signed char cdbk_nb_high2[];
55 |
56 | /* Quantizes narrowband LSPs with 30 bits */
57 | void lsp_quant_nb(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits);
58 |
59 | /* Decodes quantized narrowband LSPs */
60 | void lsp_unquant_nb(spx_lsp_t *lsp, int order, SpeexBits *bits);
61 |
62 | /* Quantizes low bit-rate narrowband LSPs with 18 bits */
63 | void lsp_quant_lbr(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits);
64 |
65 | /* Decodes quantized low bit-rate narrowband LSPs */
66 | void lsp_unquant_lbr(spx_lsp_t *lsp, int order, SpeexBits *bits);
67 |
68 | /* Quantizes high-band LSPs with 12 bits */
69 | void lsp_quant_high(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits);
70 |
71 | /* Decodes high-band LSPs */
72 | void lsp_unquant_high(spx_lsp_t *lsp, int order, SpeexBits *bits);
73 |
74 | #endif
75 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/smallft.h:
--------------------------------------------------------------------------------
1 | /********************************************************************
2 | * *
3 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
7 | * *
8 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
9 | * by the XIPHOPHORUS Company http://www.xiph.org/ *
10 | * *
11 | ********************************************************************
12 |
13 | function: fft transform
14 | last mod: $Id: smallft.h,v 1.3 2003/09/16 18:35:45 jm Exp $
15 |
16 | ********************************************************************/
17 | /**
18 | @file smallft.h
19 | @brief Discrete Rotational Fourier Transform (DRFT)
20 | */
21 |
22 | #ifndef _V_SMFT_H_
23 | #define _V_SMFT_H_
24 |
25 |
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 |
30 | /** Discrete Rotational Fourier Transform lookup */
31 | struct drft_lookup{
32 | int n;
33 | float *trigcache;
34 | int *splitcache;
35 | };
36 |
37 | extern void spx_drft_forward(struct drft_lookup *l,float *data);
38 | extern void spx_drft_backward(struct drft_lookup *l,float *data);
39 | extern void spx_drft_init(struct drft_lookup *l,int n);
40 | extern void spx_drft_clear(struct drft_lookup *l);
41 |
42 | #ifdef __cplusplus
43 | }
44 | #endif
45 |
46 | #endif
47 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/speex_callbacks.c:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2002 Jean-Marc Valin
2 | File speex_callbacks.c
3 | Callback handling and in-band signalling
4 |
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions
8 | are met:
9 |
10 | - Redistributions of source code must retain the above copyright
11 | notice, this list of conditions and the following disclaimer.
12 |
13 | - Redistributions in binary form must reproduce the above copyright
14 | notice, this list of conditions and the following disclaimer in the
15 | documentation and/or other materials provided with the distribution.
16 |
17 | - Neither the name of the Xiph.org Foundation nor the names of its
18 | contributors may be used to endorse or promote products derived from
19 | this software without specific prior written permission.
20 |
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 |
33 | */
34 |
35 | #ifdef HAVE_CONFIG_H
36 | #include "config.h"
37 | #endif
38 |
39 | #include "speex/speex_callbacks.h"
40 | #include "arch.h"
41 | #include "os_support.h"
42 |
43 | EXPORT int speex_inband_handler(SpeexBits *bits, SpeexCallback *callback_list, void *state)
44 | {
45 | int id;
46 | SpeexCallback *callback;
47 | /*speex_bits_advance(bits, 5);*/
48 | id=speex_bits_unpack_unsigned(bits, 4);
49 | callback = callback_list+id;
50 |
51 | if (callback->func)
52 | {
53 | return callback->func(bits, state, callback->data);
54 | } else
55 | /*If callback is not registered, skip the right number of bits*/
56 | {
57 | int adv;
58 | if (id<2)
59 | adv = 1;
60 | else if (id<8)
61 | adv = 4;
62 | else if (id<10)
63 | adv = 8;
64 | else if (id<12)
65 | adv = 16;
66 | else if (id<14)
67 | adv = 32;
68 | else
69 | adv = 64;
70 | speex_bits_advance(bits, adv);
71 | }
72 | return 0;
73 | }
74 |
75 | EXPORT int speex_std_mode_request_handler(SpeexBits *bits, void *state, void *data)
76 | {
77 | spx_int32_t m;
78 | m = speex_bits_unpack_unsigned(bits, 4);
79 | speex_encoder_ctl(data, SPEEX_SET_MODE, &m);
80 | return 0;
81 | }
82 |
83 | EXPORT int speex_std_low_mode_request_handler(SpeexBits *bits, void *state, void *data)
84 | {
85 | spx_int32_t m;
86 | m = speex_bits_unpack_unsigned(bits, 4);
87 | speex_encoder_ctl(data, SPEEX_SET_LOW_MODE, &m);
88 | return 0;
89 | }
90 |
91 | EXPORT int speex_std_high_mode_request_handler(SpeexBits *bits, void *state, void *data)
92 | {
93 | spx_int32_t m;
94 | m = speex_bits_unpack_unsigned(bits, 4);
95 | speex_encoder_ctl(data, SPEEX_SET_HIGH_MODE, &m);
96 | return 0;
97 | }
98 |
99 | #ifndef DISABLE_VBR
100 | EXPORT int speex_std_vbr_request_handler(SpeexBits *bits, void *state, void *data)
101 | {
102 | spx_int32_t vbr;
103 | vbr = speex_bits_unpack_unsigned(bits, 1);
104 | speex_encoder_ctl(data, SPEEX_SET_VBR, &vbr);
105 | return 0;
106 | }
107 | #endif /* #ifndef DISABLE_VBR */
108 |
109 | EXPORT int speex_std_enh_request_handler(SpeexBits *bits, void *state, void *data)
110 | {
111 | spx_int32_t enh;
112 | enh = speex_bits_unpack_unsigned(bits, 1);
113 | speex_decoder_ctl(data, SPEEX_SET_ENH, &enh);
114 | return 0;
115 | }
116 |
117 | #ifndef DISABLE_VBR
118 | EXPORT int speex_std_vbr_quality_request_handler(SpeexBits *bits, void *state, void *data)
119 | {
120 | float qual;
121 | qual = speex_bits_unpack_unsigned(bits, 4);
122 | speex_encoder_ctl(data, SPEEX_SET_VBR_QUALITY, &qual);
123 | return 0;
124 | }
125 | #endif /* #ifndef DISABLE_VBR */
126 |
127 | EXPORT int speex_std_char_handler(SpeexBits *bits, void *state, void *data)
128 | {
129 | unsigned char ch;
130 | ch = speex_bits_unpack_unsigned(bits, 8);
131 | _speex_putc(ch, data);
132 | /*printf("speex_std_char_handler ch=%x\n", ch);*/
133 | return 0;
134 | }
135 |
136 |
137 |
138 | /* Default handler for user callbacks: skip it */
139 | EXPORT int speex_default_user_handler(SpeexBits *bits, void *state, void *data)
140 | {
141 | int req_size = speex_bits_unpack_unsigned(bits, 4);
142 | speex_bits_advance(bits, 5+8*req_size);
143 | return 0;
144 | }
145 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/stack_alloc.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2002 Jean-Marc Valin */
2 | /**
3 | @file stack_alloc.h
4 | @brief Temporary memory allocation on stack
5 | */
6 | /*
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | - Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 |
14 | - Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions and the following disclaimer in the
16 | documentation and/or other materials provided with the distribution.
17 |
18 | - Neither the name of the Xiph.org Foundation nor the names of its
19 | contributors may be used to endorse or promote products derived from
20 | this software without specific prior written permission.
21 |
22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef STACK_ALLOC_H
36 | #define STACK_ALLOC_H
37 |
38 | #ifdef USE_ALLOCA
39 | # ifdef WIN32
40 | # include
41 | # else
42 | # ifdef HAVE_ALLOCA_H
43 | # include
44 | # else
45 | # include
46 | # endif
47 | # endif
48 | #endif
49 |
50 | /**
51 | * @def ALIGN(stack, size)
52 | *
53 | * Aligns the stack to a 'size' boundary
54 | *
55 | * @param stack Stack
56 | * @param size New size boundary
57 | */
58 |
59 | /**
60 | * @def PUSH(stack, size, type)
61 | *
62 | * Allocates 'size' elements of type 'type' on the stack
63 | *
64 | * @param stack Stack
65 | * @param size Number of elements
66 | * @param type Type of element
67 | */
68 |
69 | /**
70 | * @def VARDECL(var)
71 | *
72 | * Declare variable on stack
73 | *
74 | * @param var Variable to declare
75 | */
76 |
77 | /**
78 | * @def ALLOC(var, size, type)
79 | *
80 | * Allocate 'size' elements of 'type' on stack
81 | *
82 | * @param var Name of variable to allocate
83 | * @param size Number of elements
84 | * @param type Type of element
85 | */
86 |
87 | #ifdef ENABLE_VALGRIND
88 |
89 | #include
90 |
91 | #define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1))
92 |
93 | #define PUSH(stack, size, type) (VALGRIND_MAKE_NOACCESS(stack, 1000),ALIGN((stack),sizeof(type)),VALGRIND_MAKE_WRITABLE(stack, ((size)*sizeof(type))),(stack)+=((size)*sizeof(type)),(type*)((stack)-((size)*sizeof(type))))
94 |
95 | #else
96 |
97 | #define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1))
98 |
99 | #define PUSH(stack, size, type) (ALIGN((stack),sizeof(type)),(stack)+=((size)*sizeof(type)),(type*)((stack)-((size)*sizeof(type))))
100 |
101 | #endif
102 |
103 | #if defined(VAR_ARRAYS)
104 | #define VARDECL(var)
105 | #define ALLOC(var, size, type) type var[size]
106 | #elif defined(USE_ALLOCA)
107 | #define VARDECL(var) var
108 | #define ALLOC(var, size, type) var = alloca(sizeof(type)*(size))
109 | #else
110 | #define VARDECL(var) var
111 | #define ALLOC(var, size, type) var = PUSH(stack, size, type)
112 | #endif
113 |
114 |
115 | #endif
116 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/testenc.c:
--------------------------------------------------------------------------------
1 | #ifdef HAVE_CONFIG_H
2 | #include "config.h"
3 | #endif
4 |
5 | #include "speex/speex_callbacks.h"
6 | #include
7 | #include
8 |
9 | #ifdef FIXED_DEBUG
10 | extern long long spx_mips;
11 | #endif
12 |
13 | #define FRAME_SIZE 160
14 | #include
15 | int main(int argc, char **argv)
16 | {
17 | char *inFile, *outFile, *bitsFile;
18 | FILE *fin, *fout, *fbits=NULL;
19 | short in_short[FRAME_SIZE];
20 | short out_short[FRAME_SIZE];
21 | int snr_frames = 0;
22 | char cbits[200];
23 | int nbBits;
24 | int i;
25 | void *st;
26 | void *dec;
27 | SpeexBits bits;
28 | spx_int32_t tmp;
29 | int bitCount=0;
30 | spx_int32_t skip_group_delay;
31 | SpeexCallback callback;
32 |
33 | st = speex_encoder_init(speex_lib_get_mode(SPEEX_MODEID_NB));
34 | dec = speex_decoder_init(speex_lib_get_mode(SPEEX_MODEID_NB));
35 |
36 | /* BEGIN: You probably don't need the following in a real application */
37 | callback.callback_id = SPEEX_INBAND_CHAR;
38 | callback.func = speex_std_char_handler;
39 | callback.data = stderr;
40 | speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
41 |
42 | callback.callback_id = SPEEX_INBAND_MODE_REQUEST;
43 | callback.func = speex_std_mode_request_handler;
44 | callback.data = st;
45 | speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
46 | /* END of unnecessary stuff */
47 |
48 | tmp=1;
49 | speex_decoder_ctl(dec, SPEEX_SET_ENH, &tmp);
50 | tmp=0;
51 | speex_encoder_ctl(st, SPEEX_SET_VBR, &tmp);
52 | tmp=8;
53 | speex_encoder_ctl(st, SPEEX_SET_QUALITY, &tmp);
54 | tmp=1;
55 | speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &tmp);
56 |
57 | /* Turn this off if you want to measure SNR (on by default) */
58 | tmp=1;
59 | speex_encoder_ctl(st, SPEEX_SET_HIGHPASS, &tmp);
60 | speex_decoder_ctl(dec, SPEEX_SET_HIGHPASS, &tmp);
61 |
62 | speex_encoder_ctl(st, SPEEX_GET_LOOKAHEAD, &skip_group_delay);
63 | speex_decoder_ctl(dec, SPEEX_GET_LOOKAHEAD, &tmp);
64 | skip_group_delay += tmp;
65 |
66 | if (argc != 4 && argc != 3)
67 | {
68 | fprintf (stderr, "Usage: encode [in file] [out file] [bits file]\nargc = %d", argc);
69 | exit(1);
70 | }
71 | inFile = argv[1];
72 | fin = fopen(inFile, "rb");
73 | outFile = argv[2];
74 | fout = fopen(outFile, "wb+");
75 | if (argc==4)
76 | {
77 | bitsFile = argv[3];
78 | fbits = fopen(bitsFile, "wb");
79 | }
80 | speex_bits_init(&bits);
81 | while (!feof(fin))
82 | {
83 | fread(in_short, sizeof(short), FRAME_SIZE, fin);
84 | if (feof(fin))
85 | break;
86 | speex_bits_reset(&bits);
87 |
88 | speex_encode_int(st, in_short, &bits);
89 | nbBits = speex_bits_write(&bits, cbits, 200);
90 | bitCount+=bits.nbBits;
91 |
92 | if (argc==4)
93 | fwrite(cbits, 1, nbBits, fbits);
94 | speex_bits_rewind(&bits);
95 |
96 | speex_decode_int(dec, &bits, out_short);
97 | speex_bits_reset(&bits);
98 |
99 | fwrite(&out_short[skip_group_delay], sizeof(short), FRAME_SIZE-skip_group_delay, fout);
100 | skip_group_delay = 0;
101 | }
102 | fprintf (stderr, "Total encoded size: %d bits\n", bitCount);
103 | speex_encoder_destroy(st);
104 | speex_decoder_destroy(dec);
105 | speex_bits_destroy(&bits);
106 |
107 | #ifndef DISABLE_FLOAT_API
108 | {
109 | float sigpow,errpow,snr, seg_snr=0;
110 | sigpow = 0;
111 | errpow = 0;
112 |
113 | /* This code just computes SNR, so you don't need it either */
114 | rewind(fin);
115 | rewind(fout);
116 |
117 | while ( FRAME_SIZE == fread(in_short, sizeof(short), FRAME_SIZE, fin)
118 | &&
119 | FRAME_SIZE == fread(out_short, sizeof(short), FRAME_SIZE,fout) )
120 | {
121 | float s=0, e=0;
122 | for (i=0;i
7 | #include
8 |
9 | #ifdef FIXED_DEBUG
10 | extern long long spx_mips;
11 | #endif
12 |
13 | #define FRAME_SIZE 640
14 | #include
15 | int main(int argc, char **argv)
16 | {
17 | char *inFile, *outFile, *bitsFile;
18 | FILE *fin, *fout, *fbits=NULL;
19 | short in_short[FRAME_SIZE];
20 | short out_short[FRAME_SIZE];
21 | float sigpow,errpow,snr, seg_snr=0;
22 | int snr_frames = 0;
23 | char cbits[200];
24 | int nbBits;
25 | int i;
26 | void *st;
27 | void *dec;
28 | SpeexBits bits;
29 | spx_int32_t tmp;
30 | int bitCount=0;
31 | spx_int32_t skip_group_delay;
32 | SpeexCallback callback;
33 |
34 | sigpow = 0;
35 | errpow = 0;
36 |
37 | st = speex_encoder_init(speex_lib_get_mode(SPEEX_MODEID_UWB));
38 | dec = speex_decoder_init(speex_lib_get_mode(SPEEX_MODEID_UWB));
39 |
40 | callback.callback_id = SPEEX_INBAND_CHAR;
41 | callback.func = speex_std_char_handler;
42 | callback.data = stderr;
43 | speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
44 |
45 | callback.callback_id = SPEEX_INBAND_MODE_REQUEST;
46 | callback.func = speex_std_mode_request_handler;
47 | callback.data = st;
48 | speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
49 |
50 | tmp=0;
51 | speex_decoder_ctl(dec, SPEEX_SET_ENH, &tmp);
52 | tmp=0;
53 | speex_encoder_ctl(st, SPEEX_SET_VBR, &tmp);
54 | tmp=7;
55 | speex_encoder_ctl(st, SPEEX_SET_QUALITY, &tmp);
56 | tmp=1;
57 | speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &tmp);
58 |
59 | speex_encoder_ctl(st, SPEEX_GET_LOOKAHEAD, &skip_group_delay);
60 | speex_decoder_ctl(dec, SPEEX_GET_LOOKAHEAD, &tmp);
61 | skip_group_delay += tmp;
62 |
63 |
64 | if (argc != 4 && argc != 3)
65 | {
66 | fprintf (stderr, "Usage: encode [in file] [out file] [bits file]\nargc = %d", argc);
67 | exit(1);
68 | }
69 | inFile = argv[1];
70 | fin = fopen(inFile, "rb");
71 | outFile = argv[2];
72 | fout = fopen(outFile, "wb+");
73 | if (argc==4)
74 | {
75 | bitsFile = argv[3];
76 | fbits = fopen(bitsFile, "wb");
77 | }
78 | speex_bits_init(&bits);
79 | while (!feof(fin))
80 | {
81 | fread(in_short, sizeof(short), FRAME_SIZE, fin);
82 | if (feof(fin))
83 | break;
84 | speex_bits_reset(&bits);
85 |
86 | speex_encode_int(st, in_short, &bits);
87 | nbBits = speex_bits_write(&bits, cbits, 200);
88 | bitCount+=bits.nbBits;
89 |
90 | if (argc==4)
91 | fwrite(cbits, 1, nbBits, fbits);
92 | speex_bits_rewind(&bits);
93 |
94 | speex_decode_int(dec, &bits, out_short);
95 | speex_bits_reset(&bits);
96 |
97 | fwrite(&out_short[skip_group_delay], sizeof(short), FRAME_SIZE-skip_group_delay, fout);
98 | skip_group_delay = 0;
99 | }
100 | fprintf (stderr, "Total encoded size: %d bits\n", bitCount);
101 | speex_encoder_destroy(st);
102 | speex_decoder_destroy(dec);
103 |
104 | rewind(fin);
105 | rewind(fout);
106 |
107 | while ( FRAME_SIZE == fread(in_short, sizeof(short), FRAME_SIZE, fin)
108 | &&
109 | FRAME_SIZE == fread(out_short, sizeof(short), FRAME_SIZE,fout) )
110 | {
111 | float s=0, e=0;
112 | for (i=0;i
7 | #include
8 |
9 | #ifdef FIXED_DEBUG
10 | extern long long spx_mips;
11 | #endif
12 |
13 | #define FRAME_SIZE 320
14 | #include
15 | int main(int argc, char **argv)
16 | {
17 | char *inFile, *outFile, *bitsFile;
18 | FILE *fin, *fout, *fbits=NULL;
19 | short in_short[FRAME_SIZE];
20 | short out_short[FRAME_SIZE];
21 | float sigpow,errpow,snr, seg_snr=0;
22 | int snr_frames = 0;
23 | char cbits[200];
24 | int nbBits;
25 | int i;
26 | void *st;
27 | void *dec;
28 | SpeexBits bits;
29 | spx_int32_t tmp;
30 | int bitCount=0;
31 | spx_int32_t skip_group_delay;
32 | SpeexCallback callback;
33 |
34 | sigpow = 0;
35 | errpow = 0;
36 |
37 | st = speex_encoder_init(speex_lib_get_mode(SPEEX_MODEID_WB));
38 | dec = speex_decoder_init(speex_lib_get_mode(SPEEX_MODEID_WB));
39 |
40 | callback.callback_id = SPEEX_INBAND_CHAR;
41 | callback.func = speex_std_char_handler;
42 | callback.data = stderr;
43 | speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
44 |
45 | callback.callback_id = SPEEX_INBAND_MODE_REQUEST;
46 | callback.func = speex_std_mode_request_handler;
47 | callback.data = st;
48 | speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
49 |
50 | tmp=1;
51 | speex_decoder_ctl(dec, SPEEX_SET_ENH, &tmp);
52 | tmp=0;
53 | speex_encoder_ctl(st, SPEEX_SET_VBR, &tmp);
54 | tmp=8;
55 | speex_encoder_ctl(st, SPEEX_SET_QUALITY, &tmp);
56 | tmp=3;
57 | speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &tmp);
58 | /*tmp=3;
59 | speex_encoder_ctl(st, SPEEX_SET_HIGH_MODE, &tmp);
60 | tmp=6;
61 | speex_encoder_ctl(st, SPEEX_SET_LOW_MODE, &tmp);
62 | */
63 |
64 | speex_encoder_ctl(st, SPEEX_GET_LOOKAHEAD, &skip_group_delay);
65 | speex_decoder_ctl(dec, SPEEX_GET_LOOKAHEAD, &tmp);
66 | skip_group_delay += tmp;
67 |
68 |
69 | if (argc != 4 && argc != 3)
70 | {
71 | fprintf (stderr, "Usage: encode [in file] [out file] [bits file]\nargc = %d", argc);
72 | exit(1);
73 | }
74 | inFile = argv[1];
75 | fin = fopen(inFile, "rb");
76 | outFile = argv[2];
77 | fout = fopen(outFile, "wb+");
78 | if (argc==4)
79 | {
80 | bitsFile = argv[3];
81 | fbits = fopen(bitsFile, "wb");
82 | }
83 | speex_bits_init(&bits);
84 | while (!feof(fin))
85 | {
86 | fread(in_short, sizeof(short), FRAME_SIZE, fin);
87 | if (feof(fin))
88 | break;
89 | speex_bits_reset(&bits);
90 |
91 | speex_encode_int(st, in_short, &bits);
92 | nbBits = speex_bits_write(&bits, cbits, 200);
93 | bitCount+=bits.nbBits;
94 |
95 | if (argc==4)
96 | fwrite(cbits, 1, nbBits, fbits);
97 | speex_bits_rewind(&bits);
98 |
99 | speex_decode_int(dec, &bits, out_short);
100 | speex_bits_reset(&bits);
101 |
102 | fwrite(&out_short[skip_group_delay], sizeof(short), FRAME_SIZE-skip_group_delay, fout);
103 | skip_group_delay = 0;
104 | }
105 | fprintf (stderr, "Total encoded size: %d bits\n", bitCount);
106 | speex_encoder_destroy(st);
107 | speex_decoder_destroy(dec);
108 | speex_bits_destroy(&bits);
109 |
110 | rewind(fin);
111 | rewind(fout);
112 |
113 | while ( FRAME_SIZE == fread(in_short, sizeof(short), FRAME_SIZE, fin)
114 | &&
115 | FRAME_SIZE == fread(out_short, sizeof(short), FRAME_SIZE,fout) )
116 | {
117 | float s=0, e=0;
118 | for (i=0;i1e-13?log((x)*(x))*4.34294480f:-30)
43 | #define fromdB(x) (exp((x)*.11512925f))
44 |
45 | /* The bark scale equations are approximations, since the original
46 | table was somewhat hand rolled. The below are chosen to have the
47 | best possible fit to the rolled tables, thus their somewhat odd
48 | appearance (these are more accurate and over a longer range than
49 | the oft-quoted bark equations found in the texts I have). The
50 | approximations are valid from 0 - 30kHz (nyquist) or so.
51 |
52 | all f in Hz, z in Bark */
53 |
54 | #define toBARK(n) (13.1f*atan(.00074f*(n))+2.24f*atan((n)*(n)*1.85e-8f)+1e-4f*(n))
55 | #define fromBARK(z) (102.f*(z)-2.f*pow(z,2.f)+.4f*pow(z,3.f)+pow(1.46f,z)-1.f)
56 |
57 | /* Frequency to octave. We arbitrarily declare 63.5 Hz to be octave
58 | 0.0 */
59 |
60 | #define toOC(n) (log(n)*1.442695f-5.965784f)
61 | #define fromOC(o) (exp(((o)+5.965784f)*.693147f))
62 |
63 |
64 | typedef struct {
65 |
66 | float noisewindowlo;
67 | float noisewindowhi;
68 | int noisewindowlomin;
69 | int noisewindowhimin;
70 | int noisewindowfixed;
71 | float noiseoff[P_BANDS];
72 | float noisecompand[NOISE_COMPAND_LEVELS];
73 |
74 | } VorbisPsyInfo;
75 |
76 |
77 |
78 | typedef struct {
79 | int n;
80 | int rate;
81 | struct drft_lookup lookup;
82 | VorbisPsyInfo *vi;
83 |
84 | float *window;
85 | float *noiseoffset;
86 | long *bark;
87 |
88 | } VorbisPsy;
89 |
90 |
91 | VorbisPsy *vorbis_psy_init(int rate, int size);
92 | void vorbis_psy_destroy(VorbisPsy *psy);
93 | void compute_curve(VorbisPsy *psy, float *audio, float *curve);
94 | void curve_to_lpc(VorbisPsy *psy, float *curve, float *awk1, float *awk2, int ord);
95 |
96 | #endif
97 | #endif
98 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/vq.c:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2002 Jean-Marc Valin
2 | File: vq.c
3 | Vector quantization
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions
7 | are met:
8 |
9 | - Redistributions of source code must retain the above copyright
10 | notice, this list of conditions and the following disclaimer.
11 |
12 | - Redistributions in binary form must reproduce the above copyright
13 | notice, this list of conditions and the following disclaimer in the
14 | documentation and/or other materials provided with the distribution.
15 |
16 | - Neither the name of the Xiph.org Foundation nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
24 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 | */
32 |
33 | #ifdef HAVE_CONFIG_H
34 | #include "config.h"
35 | #endif
36 |
37 | #include "vq.h"
38 | #include "stack_alloc.h"
39 | #include "arch.h"
40 |
41 | #ifdef _USE_SSE
42 | #include
43 | #include "vq_sse.h"
44 | #elif defined(SHORTCUTS) && (defined(ARM4_ASM) || defined(ARM5E_ASM))
45 | #include "vq_arm4.h"
46 | #elif defined(BFIN_ASM)
47 | #include "vq_bfin.h"
48 | #endif
49 |
50 | #ifndef DISABLE_ENCODER
51 | int scal_quant(spx_word16_t in, const spx_word16_t *boundary, int entries)
52 | {
53 | int i=0;
54 | while (iboundary[0])
55 | {
56 | boundary++;
57 | i++;
58 | }
59 | return i;
60 | }
61 |
62 | int scal_quant32(spx_word32_t in, const spx_word32_t *boundary, int entries)
63 | {
64 | int i=0;
65 | while (iboundary[0])
66 | {
67 | boundary++;
68 | i++;
69 | }
70 | return i;
71 | }
72 | #endif /* DISABLE_ENCODER */
73 |
74 | #if !defined(OVERRIDE_VQ_NBEST) && !defined(DISABLE_ENCODER)
75 | /*Finds the indices of the n-best entries in a codebook*/
76 | void vq_nbest(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack)
77 | {
78 | int i,j,k,used;
79 | used = 0;
80 | for (i=0;i= 1) && (k > used || dist < best_dist[k-1]); k--)
93 | {
94 | best_dist[k]=best_dist[k-1];
95 | nbest[k] = nbest[k-1];
96 | }
97 | best_dist[k]=dist;
98 | nbest[k]=i;
99 | used++;
100 | }
101 | }
102 | }
103 | #endif /* !defined(OVERRIDE_VQ_NBEST) && !defined(DISABLE_ENCODER) */
104 |
105 |
106 |
107 |
108 | #if !defined(OVERRIDE_VQ_NBEST_SIGN) && !defined(DISABLE_WIDEBAND) && !defined(DISABLE_ENCODER)
109 | /*Finds the indices of the n-best entries in a codebook with sign*/
110 | void vq_nbest_sign(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack)
111 | {
112 | int i,j,k, sign, used;
113 | used=0;
114 | for (i=0;i0)
120 | {
121 | sign=0;
122 | dist=-dist;
123 | } else
124 | {
125 | sign=1;
126 | }
127 | #ifdef FIXED_POINT
128 | dist = ADD32(dist,SHR32(E[i],1));
129 | #else
130 | dist = ADD32(dist,.5f*E[i]);
131 | #endif
132 | if (i= 1) && (k > used || dist < best_dist[k-1]); k--)
135 | {
136 | best_dist[k]=best_dist[k-1];
137 | nbest[k] = nbest[k-1];
138 | }
139 | best_dist[k]=dist;
140 | nbest[k]=i;
141 | used++;
142 | if (sign)
143 | nbest[k]+=entries;
144 | }
145 | }
146 | }
147 | #endif /* !defined(OVERRIDE_VQ_NBEST_SIGN) && !defined(DISABLE_WIDEBAND) && !defined(DISABLE_ENCODER) */
148 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/vq.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2002 Jean-Marc Valin */
2 | /**
3 | @file vq.h
4 | @brief Vector quantization
5 | */
6 | /*
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | - Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 |
14 | - Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions and the following disclaimer in the
16 | documentation and/or other materials provided with the distribution.
17 |
18 | - Neither the name of the Xiph.org Foundation nor the names of its
19 | contributors may be used to endorse or promote products derived from
20 | this software without specific prior written permission.
21 |
22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef VQ_H
36 | #define VQ_H
37 |
38 | #include "arch.h"
39 |
40 | int scal_quant(spx_word16_t in, const spx_word16_t *boundary, int entries);
41 | int scal_quant32(spx_word32_t in, const spx_word32_t *boundary, int entries);
42 |
43 | #ifdef _USE_SSE
44 | #include
45 | void vq_nbest(spx_word16_t *in, const __m128 *codebook, int len, int entries, __m128 *E, int N, int *nbest, spx_word32_t *best_dist, char *stack);
46 |
47 | void vq_nbest_sign(spx_word16_t *in, const __m128 *codebook, int len, int entries, __m128 *E, int N, int *nbest, spx_word32_t *best_dist, char *stack);
48 | #else
49 | void vq_nbest(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack);
50 |
51 | void vq_nbest_sign(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack);
52 | #endif
53 |
54 | #endif
55 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/vq_arm4.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2004 Jean-Marc Valin */
2 | /**
3 | @file vq_arm4.h
4 | @brief ARM4-optimized vq routine
5 | */
6 | /*
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | - Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 |
14 | - Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions and the following disclaimer in the
16 | documentation and/or other materials provided with the distribution.
17 |
18 | - Neither the name of the Xiph.org Foundation nor the names of its
19 | contributors may be used to endorse or promote products derived from
20 | this software without specific prior written permission.
21 |
22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #define OVERRIDE_VQ_NBEST
36 | void vq_nbest(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack)
37 | {
38 | int i,j;
39 | for (i=0;i>= 1;\n\t"
57 | "A0 = %0;\n\t"
58 | "R0.L = W[%1++%7] || R1.L = W[I0++];\n\t"
59 | "LOOP vq_loop%= LC1 = %5;\n\t"
60 | "LOOP_BEGIN vq_loop%=;\n\t"
61 | "%0 = (A0 -= R0.L*R1.L) (IS) || R0.L = W[%1++%7] || R1.L = W[I0++];\n\t"
62 | "LOOP_END vq_loop%=;\n\t"
63 | "%0 = (A0 -= R0.L*R1.L) (IS);\n\t"
64 | "cc = %0 < %2;\n\t"
65 | "if cc %2 = %0;\n\t"
66 | "if cc %3 = R2;\n\t"
67 | "R2 += 1;\n\t"
68 | "LOOP_END entries_loop%=;\n\t"
69 | : "=&D" (dist), "=&a" (codebook), "=&d" (best_dist[0]), "=&d" (nbest[0]), "=&a" (E)
70 | : "a" (len-1), "a" (in), "a" (2), "d" (entries), "d" (len<<1), "1" (codebook), "4" (E), "2" (best_dist[0]), "3" (nbest[0])
71 | : "R0", "R1", "R2", "I0", "L0", "B0", "A0", "cc", "memory",
72 | "ASTAT" BFIN_HWLOOP0_REGS BFIN_HWLOOP1_REGS
73 | );
74 | }
75 | } else {
76 | int i,k,used;
77 | used = 0;
78 | for (i=0;i>= 1;\n\t"
84 | "A0 = %0;\n\t"
85 | "I0 = %3;\n\t"
86 | "L0 = 0;\n\t"
87 | "R0.L = W[%1++%4] || R1.L = W[I0++];\n\t"
88 | "LOOP vq_loop%= LC0 = %2;\n\t"
89 | "LOOP_BEGIN vq_loop%=;\n\t"
90 | "%0 = (A0 -= R0.L*R1.L) (IS) || R0.L = W[%1++%4] || R1.L = W[I0++];\n\t"
91 | "LOOP_END vq_loop%=;\n\t"
92 | "%0 = (A0 -= R0.L*R1.L) (IS);\n\t"
93 | : "=D" (dist), "=a" (codebook)
94 | : "a" (len-1), "a" (in), "a" (2), "1" (codebook), "0" (E[i])
95 | : "R0", "R1", "I0", "L0", "A0", "ASTAT" BFIN_HWLOOP0_REGS
96 | );
97 | if (i= 1) && (k > used || dist < best_dist[k-1]); k--)
100 | {
101 | best_dist[k]=best_dist[k-1];
102 | nbest[k] = nbest[k-1];
103 | }
104 | best_dist[k]=dist;
105 | nbest[k]=i;
106 | used++;
107 | }
108 | }
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/libspeex/vq_sse.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2004 Jean-Marc Valin */
2 | /**
3 | @file vq_sse.h
4 | @brief SSE-optimized vq routine
5 | */
6 | /*
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | - Redistributions of source code must retain the above copyright
12 | notice, this list of conditions and the following disclaimer.
13 |
14 | - Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions and the following disclaimer in the
16 | documentation and/or other materials provided with the distribution.
17 |
18 | - Neither the name of the Xiph.org Foundation nor the names of its
19 | contributors may be used to endorse or promote products derived from
20 | this software without specific prior written permission.
21 |
22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #define OVERRIDE_VQ_NBEST
36 | void vq_nbest(spx_word16_t *_in, const __m128 *codebook, int len, int entries, __m128 *E, int N, int *nbest, spx_word32_t *best_dist, char *stack)
37 | {
38 | int i,j,k,used;
39 | VARDECL(float *dist);
40 | VARDECL(__m128 *in);
41 | __m128 half;
42 | used = 0;
43 | ALLOC(dist, entries, float);
44 | half = _mm_set_ps1(.5f);
45 | ALLOC(in, len, __m128);
46 | for (i=0;i>2;i++)
49 | {
50 | __m128 d = _mm_mul_ps(E[i], half);
51 | for (j=0;j= 1) && (k > used || dist[i] < best_dist[k-1]); k--)
60 | {
61 | best_dist[k]=best_dist[k-1];
62 | nbest[k] = nbest[k-1];
63 | }
64 | best_dist[k]=dist[i];
65 | nbest[k]=i;
66 | used++;
67 | }
68 | }
69 | }
70 |
71 |
72 |
73 |
74 | #define OVERRIDE_VQ_NBEST_SIGN
75 | void vq_nbest_sign(spx_word16_t *_in, const __m128 *codebook, int len, int entries, __m128 *E, int N, int *nbest, spx_word32_t *best_dist, char *stack)
76 | {
77 | int i,j,k,used;
78 | VARDECL(float *dist);
79 | VARDECL(__m128 *in);
80 |
81 | used = 0;
82 | ALLOC(dist, entries, float);
83 |
84 | ALLOC(in, len, __m128);
85 | for (i=0;i>2;i++)
88 | {
89 | __m128 d = _mm_setzero_ps();
90 | for (j=0;j0)
98 | {
99 | sign=0;
100 | dist[i]=-dist[i];
101 | } else
102 | {
103 | sign=1;
104 | }
105 | dist[i] += .5f*((float*)E)[i];
106 | if (i= 1) && (k > used || dist[i] < best_dist[k-1]); k--)
109 | {
110 | best_dist[k]=best_dist[k-1];
111 | nbest[k] = nbest[k-1];
112 | }
113 | best_dist[k]=dist[i];
114 | nbest[k]=i;
115 | used++;
116 | if (sign)
117 | nbest[k]+=entries;
118 | }
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/lib/src/main/cpp/speex/speex_jni.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018, VIA Technologies, Inc. & OLAMI Team.
3 |
4 | http://olami.ai
5 |
6 | Licensed under the Apache License, Version 2.0 (the "License");
7 | you may not use this file except in compliance with the License.
8 | You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing, software
13 | distributed under the License is distributed on an "AS IS" BASIS,
14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | See the License for the specific language governing permissions and
16 | limitations under the License.
17 | */
18 |
19 | #include
20 | #include
21 | #include
22 |
23 | #ifdef __cplusplus
24 | extern "C" {
25 | #endif
26 |
27 | static SpeexBits ebits, dbits;
28 | void *enc_state;
29 | void *dec_state;
30 | static int dec_frame_size;
31 | static int enc_frame_size;
32 |
33 |
34 | JNIEXPORT jint JNICALL
35 | Java_ai_olami_android_jni_Codec_open(JNIEnv *env, jobject instance, jint mode, jint quality) {
36 | int tmp;
37 | speex_bits_init(&ebits);
38 | speex_bits_init(&dbits);
39 |
40 | if (mode == 0) {
41 | enc_state = speex_encoder_init(&speex_nb_mode);
42 | dec_state = speex_decoder_init(&speex_nb_mode);
43 | }
44 | else if (mode == 1) {
45 | enc_state = speex_encoder_init(&speex_wb_mode);
46 | dec_state = speex_decoder_init(&speex_wb_mode);
47 | }
48 | else if (mode == 2) {
49 | enc_state = speex_encoder_init(&speex_uwb_mode);
50 | dec_state = speex_decoder_init(&speex_uwb_mode);
51 | }
52 |
53 | tmp = quality;
54 | speex_encoder_ctl(enc_state, SPEEX_SET_QUALITY, &tmp);
55 | speex_encoder_ctl(enc_state, SPEEX_GET_FRAME_SIZE, &enc_frame_size);
56 | speex_decoder_ctl(dec_state, SPEEX_GET_FRAME_SIZE, &dec_frame_size);
57 |
58 | return (jint)0;
59 |
60 | }
61 |
62 | JNIEXPORT jint JNICALL
63 | Java_ai_olami_android_jni_Codec_getFrameSize(JNIEnv *env, jobject instance) {
64 | return (jint)enc_frame_size;
65 | }
66 |
67 | JNIEXPORT jint JNICALL
68 | Java_ai_olami_android_jni_Codec_decode(JNIEnv *env, jobject instance, jbyteArray encoded,
69 | jshortArray lin, jint size) {
70 | jbyte buffer[dec_frame_size];
71 | jshort output_buffer[dec_frame_size];
72 | jsize encoded_length = size;
73 |
74 | env->GetByteArrayRegion(encoded, 0, encoded_length, buffer);
75 | speex_bits_read_from(&dbits, (char *)buffer, encoded_length);
76 | speex_decode_int(dec_state, &dbits, output_buffer);
77 | env->SetShortArrayRegion(lin, 0, dec_frame_size,
78 | output_buffer);
79 |
80 | return (jint)dec_frame_size;
81 | }
82 |
83 | JNIEXPORT jint JNICALL
84 | Java_ai_olami_android_jni_Codec_encode(JNIEnv *env, jobject instance, jshortArray lin,
85 | jint offset, jint size, jbyteArray encoded) {
86 | jshort buffer[enc_frame_size];
87 | jbyte output_buffer[enc_frame_size];
88 | int nFrames = size / enc_frame_size;
89 | int i, tot_bytes = 0;
90 | int encodedLen = 0;
91 |
92 | for (i = 0; i < nFrames; i++) {
93 | env->GetShortArrayRegion(lin, offset + i*enc_frame_size, enc_frame_size, buffer);
94 | speex_bits_reset(&ebits);
95 | speex_encode_int(enc_state, buffer, &ebits);
96 | encodedLen = speex_bits_write(&ebits, (char *)output_buffer, enc_frame_size);
97 | env->SetByteArrayRegion(encoded, tot_bytes, encodedLen, output_buffer);
98 | tot_bytes += encodedLen;
99 | }
100 | return (jint)tot_bytes;
101 | }
102 |
103 | JNIEXPORT void JNICALL
104 | Java_ai_olami_android_jni_Codec_close(JNIEnv *env, jobject instance) {
105 | speex_bits_destroy(&ebits);
106 | speex_bits_destroy(&dbits);
107 | speex_decoder_destroy(dec_state);
108 | speex_encoder_destroy(enc_state);
109 | }
110 |
111 | #ifdef __cplusplus
112 | }
113 | #endif
--------------------------------------------------------------------------------
/lib/src/main/java/ai/olami/android/IKeepRecordingSpeechRecognizerListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2017, VIA Technologies, Inc. & OLAMI Team.
3 |
4 | http://olami.ai
5 |
6 | Licensed under the Apache License, Version 2.0 (the "License");
7 | you may not use this file except in compliance with the License.
8 | You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing, software
13 | distributed under the License is distributed on an "AS IS" BASIS,
14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | See the License for the specific language governing permissions and
16 | limitations under the License.
17 | */
18 |
19 | package ai.olami.android;
20 |
21 | import ai.olami.cloudService.APIResponse;
22 |
23 | public interface IKeepRecordingSpeechRecognizerListener {
24 | /**
25 | * Callback when the recognize state changes.
26 | *
27 | * @param state - Recognize state.
28 | */
29 | void onRecognizeStateChange(
30 | KeepRecordingSpeechRecognizer.RecognizeState state
31 | );
32 |
33 | /**
34 | * Callback when the results of speech recognition changes.
35 | *
36 | * @param response - API response with all kinds of results.
37 | */
38 | void onRecognizeResultChange(APIResponse response);
39 |
40 | /**
41 | * Callback when the volume of voice input changes.
42 | *
43 | * @param volumeValue - The volume level of voice input.
44 | */
45 | void onRecordVolumeChange(int volumeValue);
46 |
47 | /**
48 | * Callback when a server error occurs.
49 | *
50 | * @param response - API response with error message.
51 | */
52 | void onServerError(APIResponse response);
53 |
54 | /**
55 | * Callback when a error occurs.
56 | *
57 | * @param error - Error type.
58 | */
59 | void onError(KeepRecordingSpeechRecognizer.Error error);
60 |
61 | /**
62 | * Callback when a exception occurs.
63 | *
64 | * @param e - Exception.
65 | */
66 | void onException(Exception e);
67 | }
68 |
--------------------------------------------------------------------------------
/lib/src/main/java/ai/olami/android/IRecorderSpeechRecognizerListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2017, VIA Technologies, Inc. & OLAMI Team.
3 |
4 | http://olami.ai
5 |
6 | Licensed under the Apache License, Version 2.0 (the "License");
7 | you may not use this file except in compliance with the License.
8 | You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing, software
13 | distributed under the License is distributed on an "AS IS" BASIS,
14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | See the License for the specific language governing permissions and
16 | limitations under the License.
17 | */
18 |
19 | package ai.olami.android;
20 |
21 | import ai.olami.cloudService.APIResponse;
22 |
23 | public interface IRecorderSpeechRecognizerListener {
24 | /**
25 | * Callback when the voice recording state changes.
26 | *
27 | * @param state - Recording state.
28 | */
29 | void onRecordStateChange(RecorderSpeechRecognizer.RecordState state);
30 |
31 | /**
32 | * Callback when the recognize process state changes.
33 | *
34 | * @param state - Recognize process state.
35 | */
36 | void onRecognizeStateChange(RecorderSpeechRecognizer.RecognizeState state);
37 |
38 | /**
39 | * Callback when the results of speech recognition changes.
40 | *
41 | * @param response - API response with all kinds of results.
42 | */
43 | void onRecognizeResultChange(APIResponse response);
44 |
45 | /**
46 | * Callback when the volume of voice input changes.
47 | *
48 | * @param volumeValue - The volume level of voice input.
49 | */
50 | void onRecordVolumeChange(int volumeValue);
51 |
52 | /**
53 | * Callback when a server error occurs.
54 | *
55 | * @param response - API response with error message.
56 | */
57 | void onServerError(APIResponse response);
58 |
59 | /**
60 | * Callback when a error occurs.
61 | *
62 | * @param error - Error type.
63 | */
64 | void onError(RecorderSpeechRecognizer.Error error);
65 |
66 | /**
67 | * Callback when a exception occurs.
68 | *
69 | * @param e - Exception.
70 | */
71 | void onException(Exception e);
72 | }
73 |
--------------------------------------------------------------------------------
/lib/src/main/java/ai/olami/android/VoiceVolume.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2017, VIA Technologies, Inc. & OLAMI Team.
3 |
4 | http://olami.ai
5 |
6 | Licensed under the Apache License, Version 2.0 (the "License");
7 | you may not use this file except in compliance with the License.
8 | You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing, software
13 | distributed under the License is distributed on an "AS IS" BASIS,
14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | See the License for the specific language governing permissions and
16 | limitations under the License.
17 | */
18 |
19 | package ai.olami.android;
20 |
21 | import java.nio.ByteBuffer;
22 | import java.nio.ByteOrder;
23 |
24 | public class VoiceVolume {
25 |
26 | public static final int VOLUME_LEVEL = 12;
27 |
28 | /**
29 | * Get audio volume from audio buffer.
30 | *
31 | * @param data - Audio buffer.
32 | * @return Volume.
33 | */
34 | public int getVoiceVolume(byte[] data){
35 | ByteBuffer byteBuffer = ByteBuffer.wrap(data);
36 | byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
37 |
38 | int v = 0;
39 | for (int i = 0 ; i < data.length ; i+=2) {
40 | if (byteBuffer.getShort(i) > v) {
41 | v = Math.abs(byteBuffer.getShort(i));
42 | }
43 | }
44 | return v;
45 | }
46 |
47 | /**
48 | * Get normalize audio volume level.
49 | *
50 | * @param volume - Volume.
51 | * @return Volume level.
52 | */
53 | public int getNormalizeVolume(int volume) {
54 | int nowVolumeMax = 10000;
55 |
56 | final int MIN_VOLUME = 1;
57 | final int MAX_VOLUME = 32767;
58 | if (volume > nowVolumeMax) {
59 | nowVolumeMax = (int) (volume * 1.5);
60 | }
61 | if (nowVolumeMax > MAX_VOLUME) {
62 | nowVolumeMax = MAX_VOLUME;
63 | }
64 |
65 | int v = volume - MIN_VOLUME;
66 | if(v < 0){
67 | v = 0;
68 | } else if (v > (nowVolumeMax - MIN_VOLUME)) {
69 | v = (nowVolumeMax - MIN_VOLUME);
70 | }
71 |
72 | int normalizeVolume = (int) ((v / (float) (nowVolumeMax - MIN_VOLUME + 1)) * (VOLUME_LEVEL + 1));
73 |
74 | return normalizeVolume;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/lib/src/main/java/ai/olami/android/jni/Codec.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018, VIA Technologies, Inc. & OLAMI Team.
3 |
4 | http://olami.ai
5 |
6 | Licensed under the Apache License, Version 2.0 (the "License");
7 | you may not use this file except in compliance with the License.
8 | You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing, software
13 | distributed under the License is distributed on an "AS IS" BASIS,
14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | See the License for the specific language governing permissions and
16 | limitations under the License.
17 | */
18 |
19 | package ai.olami.android.jni;
20 |
21 | public class Codec {
22 | static
23 | {
24 | try
25 | {
26 | System.loadLibrary("speexjni");
27 | } catch (UnsatisfiedLinkError e)
28 | {
29 | e.printStackTrace();
30 | }
31 | }
32 |
33 | private static void convertByte2Short(
34 | byte[] byData,
35 | int offset1,
36 | short[] sData,
37 | int offset2,
38 | int sizeFloat
39 | ) {
40 | if(byData.length - offset1 < 2 * sizeFloat) {
41 | throw new IllegalArgumentException("Insufficient Samples to convert to floats");
42 | } else if(sData.length - offset2 < sizeFloat) {
43 | throw new IllegalArgumentException("Insufficient float buffer to convert the samples");
44 | } else {
45 | for(int i = 0; i < sizeFloat; ++i) {
46 | sData[offset2 + i] = (short)(byData[offset1 + 2 * i] & 255 | byData[offset1 + 2 * i + 1] << 8);
47 | }
48 |
49 | }
50 | }
51 |
52 | public int encodeByte(
53 | byte lin[],
54 | int offset,
55 | int size,
56 | byte encoded[]
57 | ) {
58 | short[] sData = new short[size / 2];
59 | convertByte2Short(lin, offset, sData, 0, size / 2);
60 | return encode(sData, 0, size / 2, encoded);
61 | }
62 |
63 | public native int open(int mode, int quality);
64 | public native int getFrameSize();
65 | public native int decode(byte encoded[], short lin[], int size);
66 | public native int encode(short lin[], int offset, int size, byte encoded[]);
67 | public native void close();
68 | }
69 |
--------------------------------------------------------------------------------
/olami-apk-test-key:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olami-developers/olami-android-client-sdk/278054f18655af66421bd59f2704485e730c7d70/olami-apk-test-key
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':lib', ':examples'
2 |
--------------------------------------------------------------------------------