├── .eslintrc.js ├── .gitattributes ├── .github └── workflows │ └── gh-page.yml ├── .gitignore ├── .vscode └── settings.json ├── LICENCE ├── README.md ├── libs └── oneui-audio │ ├── .gitignore │ ├── LICENCE │ ├── README.md │ ├── build.js │ ├── index.d.ts │ ├── package.json │ ├── src │ ├── Makefile │ ├── interface │ │ ├── SKP_Silk_SDK_API.h │ │ ├── SKP_Silk_control.h │ │ ├── SKP_Silk_errors.h │ │ └── SKP_Silk_typedef.h │ ├── pre.js │ ├── src │ │ ├── SKP_Silk_A2NLSF.c │ │ ├── SKP_Silk_A2NLSF_arm.S │ │ ├── SKP_Silk_AsmHelper.h │ │ ├── SKP_Silk_AsmPreproc.h │ │ ├── SKP_Silk_CNG.c │ │ ├── SKP_Silk_HP_variable_cutoff_FIX.c │ │ ├── SKP_Silk_Inlines.h │ │ ├── SKP_Silk_LBRR_reset.c │ │ ├── SKP_Silk_LPC_inv_pred_gain.c │ │ ├── SKP_Silk_LPC_synthesis_filter.c │ │ ├── SKP_Silk_LPC_synthesis_order16.c │ │ ├── SKP_Silk_LP_variable_cutoff.c │ │ ├── SKP_Silk_LSF_cos_table.c │ │ ├── SKP_Silk_LTP_analysis_filter_FIX.c │ │ ├── SKP_Silk_LTP_scale_ctrl_FIX.c │ │ ├── SKP_Silk_MA.c │ │ ├── SKP_Silk_MA_arm.S │ │ ├── SKP_Silk_NLSF2A.c │ │ ├── SKP_Silk_NLSF2A_stable.c │ │ ├── SKP_Silk_NLSF_MSVQ_decode.c │ │ ├── SKP_Silk_NLSF_MSVQ_encode_FIX.c │ │ ├── SKP_Silk_NLSF_VQ_rate_distortion_FIX.c │ │ ├── SKP_Silk_NLSF_VQ_sum_error_FIX.c │ │ ├── SKP_Silk_NLSF_VQ_sum_error_FIX_arm.S │ │ ├── SKP_Silk_NLSF_VQ_weights_laroia.c │ │ ├── SKP_Silk_NLSF_stabilize.c │ │ ├── SKP_Silk_NSQ.c │ │ ├── SKP_Silk_NSQ_del_dec.c │ │ ├── SKP_Silk_PLC.c │ │ ├── SKP_Silk_PLC.h │ │ ├── SKP_Silk_SigProc_FIX.h │ │ ├── SKP_Silk_VAD.c │ │ ├── SKP_Silk_VQ_nearest_neighbor_FIX.c │ │ ├── SKP_Silk_allpass_int_arm.S │ │ ├── SKP_Silk_ana_filt_bank_1.c │ │ ├── SKP_Silk_ana_filt_bank_1_arm.S │ │ ├── SKP_Silk_apply_sine_window.c │ │ ├── SKP_Silk_array_maxabs.c │ │ ├── SKP_Silk_array_maxabs_arm.S │ │ ├── SKP_Silk_autocorr.c │ │ ├── SKP_Silk_biquad.c │ │ ├── SKP_Silk_biquad_alt.c │ │ ├── SKP_Silk_burg_modified.c │ │ ├── SKP_Silk_bwexpander.c │ │ ├── SKP_Silk_bwexpander_32.c │ │ ├── SKP_Silk_clz_arm.S │ │ ├── SKP_Silk_code_signs.c │ │ ├── SKP_Silk_common_pitch_est_defines.h │ │ ├── SKP_Silk_control_audio_bandwidth.c │ │ ├── SKP_Silk_control_codec_FIX.c │ │ ├── SKP_Silk_corrMatrix_FIX.c │ │ ├── SKP_Silk_create_init_destroy.c │ │ ├── SKP_Silk_dec_API.c │ │ ├── SKP_Silk_decode_core.c │ │ ├── SKP_Silk_decode_core_arm.S │ │ ├── SKP_Silk_decode_frame.c │ │ ├── SKP_Silk_decode_parameters.c │ │ ├── SKP_Silk_decode_pitch.c │ │ ├── SKP_Silk_decode_pulses.c │ │ ├── SKP_Silk_decoder_set_fs.c │ │ ├── SKP_Silk_define.h │ │ ├── SKP_Silk_detect_SWB_input.c │ │ ├── SKP_Silk_div_oabi.c │ │ ├── SKP_Silk_enc_API.c │ │ ├── SKP_Silk_encode_frame_FIX.c │ │ ├── SKP_Silk_encode_parameters.c │ │ ├── SKP_Silk_encode_pulses.c │ │ ├── SKP_Silk_find_LPC_FIX.c │ │ ├── SKP_Silk_find_LTP_FIX.c │ │ ├── SKP_Silk_find_pitch_lags_FIX.c │ │ ├── SKP_Silk_find_pred_coefs_FIX.c │ │ ├── SKP_Silk_gain_quant.c │ │ ├── SKP_Silk_init_encoder_FIX.c │ │ ├── SKP_Silk_inner_prod_aligned.c │ │ ├── SKP_Silk_inner_prod_aligned_arm.S │ │ ├── SKP_Silk_interpolate.c │ │ ├── SKP_Silk_k2a.c │ │ ├── SKP_Silk_k2a_Q16.c │ │ ├── SKP_Silk_lin2log.c │ │ ├── SKP_Silk_lin2log_arm.S │ │ ├── SKP_Silk_log2lin.c │ │ ├── SKP_Silk_macros.h │ │ ├── SKP_Silk_macros_arm.h │ │ ├── SKP_Silk_main.h │ │ ├── SKP_Silk_main_FIX.h │ │ ├── SKP_Silk_noise_shape_analysis_FIX.c │ │ ├── SKP_Silk_pitch_analysis_core.c │ │ ├── SKP_Silk_pitch_est_defines.h │ │ ├── SKP_Silk_pitch_est_tables.c │ │ ├── SKP_Silk_prefilter_FIX.c │ │ ├── SKP_Silk_prefilter_FIX_arm.S │ │ ├── SKP_Silk_process_NLSFs_FIX.c │ │ ├── SKP_Silk_process_gains_FIX.c │ │ ├── SKP_Silk_quant_LTP_gains_FIX.c │ │ ├── SKP_Silk_range_coder.c │ │ ├── SKP_Silk_regularize_correlations_FIX.c │ │ ├── SKP_Silk_resampler.c │ │ ├── SKP_Silk_resampler_down2.c │ │ ├── SKP_Silk_resampler_down2_3.c │ │ ├── SKP_Silk_resampler_down2_arm.S │ │ ├── SKP_Silk_resampler_down3.c │ │ ├── SKP_Silk_resampler_private.h │ │ ├── SKP_Silk_resampler_private_AR2.c │ │ ├── SKP_Silk_resampler_private_AR2_arm.S │ │ ├── SKP_Silk_resampler_private_ARMA4.c │ │ ├── SKP_Silk_resampler_private_ARMA4_arm.S │ │ ├── SKP_Silk_resampler_private_IIR_FIR.c │ │ ├── SKP_Silk_resampler_private_IIR_FIR_arm.S │ │ ├── SKP_Silk_resampler_private_copy.c │ │ ├── SKP_Silk_resampler_private_down4.c │ │ ├── SKP_Silk_resampler_private_down_FIR.c │ │ ├── SKP_Silk_resampler_private_down_FIR_arm.S │ │ ├── SKP_Silk_resampler_private_up2_HQ.c │ │ ├── SKP_Silk_resampler_private_up2_HQ_arm.S │ │ ├── SKP_Silk_resampler_private_up4.c │ │ ├── SKP_Silk_resampler_rom.c │ │ ├── SKP_Silk_resampler_rom.h │ │ ├── SKP_Silk_resampler_rom_arm.S │ │ ├── SKP_Silk_resampler_structs.h │ │ ├── SKP_Silk_resampler_up2.c │ │ ├── SKP_Silk_resampler_up2_arm.S │ │ ├── SKP_Silk_residual_energy16_FIX.c │ │ ├── SKP_Silk_residual_energy_FIX.c │ │ ├── SKP_Silk_scale_copy_vector16.c │ │ ├── SKP_Silk_scale_vector.c │ │ ├── SKP_Silk_schur.c │ │ ├── SKP_Silk_schur64.c │ │ ├── SKP_Silk_schur64_arm.S │ │ ├── SKP_Silk_setup_complexity.h │ │ ├── SKP_Silk_shell_coder.c │ │ ├── SKP_Silk_sigm_Q15.c │ │ ├── SKP_Silk_sigm_Q15_arm.S │ │ ├── SKP_Silk_solve_LS_FIX.c │ │ ├── SKP_Silk_sort.c │ │ ├── SKP_Silk_structs.h │ │ ├── SKP_Silk_structs_FIX.h │ │ ├── SKP_Silk_sum_sqr_shift.c │ │ ├── SKP_Silk_sum_sqr_shift_arm.S │ │ ├── SKP_Silk_tables.h │ │ ├── SKP_Silk_tables_LTP.c │ │ ├── SKP_Silk_tables_NLSF_CB0_10.c │ │ ├── SKP_Silk_tables_NLSF_CB0_10.h │ │ ├── SKP_Silk_tables_NLSF_CB0_16.c │ │ ├── SKP_Silk_tables_NLSF_CB0_16.h │ │ ├── SKP_Silk_tables_NLSF_CB1_10.c │ │ ├── SKP_Silk_tables_NLSF_CB1_10.h │ │ ├── SKP_Silk_tables_NLSF_CB1_16.c │ │ ├── SKP_Silk_tables_NLSF_CB1_16.h │ │ ├── SKP_Silk_tables_gain.c │ │ ├── SKP_Silk_tables_other.c │ │ ├── SKP_Silk_tables_pitch_lag.c │ │ ├── SKP_Silk_tables_pulses_per_block.c │ │ ├── SKP_Silk_tables_sign.c │ │ ├── SKP_Silk_tables_type_offset.c │ │ ├── SKP_Silk_tuning_parameters.h │ │ ├── SKP_Silk_warped_autocorrelation_FIX.c │ │ └── SKP_Silk_warped_autocorrelation_FIX_arm.S │ └── test │ │ ├── Decoder.c │ │ ├── Encoder.c │ │ └── signalCompare.c │ └── yarn.lock ├── package.json ├── public ├── amrnb.min.js ├── index.html ├── silksdk.js └── silksdk.wasm ├── rollup.config.js ├── scripts └── outputPublicAPI.js ├── src ├── App.svelte ├── components │ ├── chat │ │ ├── Chat.svelte │ │ └── MessageList.svelte │ ├── message │ │ ├── AtMessage.svelte │ │ ├── BFaceMessage.svelte │ │ ├── FaceMessage.svelte │ │ ├── FileMessage.svelte │ │ ├── ImageMessage.svelte │ │ ├── JSONMessage.svelte │ │ ├── Message.svelte │ │ ├── MessageBubble.svelte │ │ ├── RawMessage.svelte │ │ ├── RecordMessage.svelte │ │ ├── ReplyMessage.svelte │ │ ├── SelfMessage.svelte │ │ ├── TextMessage.svelte │ │ └── XMLMessage.svelte │ ├── settings │ │ └── Settings.svelte │ └── utils │ │ └── ImageViewer.svelte ├── custom.d.ts ├── i18n │ ├── en.ts │ ├── index.ts │ └── zh-cn.ts ├── index.ts ├── onebot │ ├── index.ts │ ├── messages.ts │ ├── raw.ts │ └── types.ts ├── stores │ ├── contact.ts │ ├── face.ts │ ├── messages.ts │ ├── self.ts │ ├── settings.ts │ ├── theme.ts │ └── users.ts └── utils │ ├── amr.d.ts │ ├── audio-worker.ts │ ├── audio.ts │ ├── base64.ts │ ├── cqcode.ts │ ├── file-icons.ts │ ├── logo.ts │ ├── silksdk.d.ts │ ├── size.ts │ └── uid.ts ├── svelte.config.js ├── theme └── _material-theme.scss ├── tsconfig.json └── yarn.lock /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | es6: true, 4 | browser: true 5 | }, 6 | extends: [ 7 | 'standard' 8 | ], 9 | globals: { 10 | Atomics: 'readonly', 11 | SharedArrayBuffer: 'readonly' 12 | }, 13 | parser: '@typescript-eslint/parser', 14 | parserOptions: { 15 | ecmaVersion: 2020, 16 | sourceType: 'module' 17 | }, 18 | plugins: [ 19 | '@typescript-eslint' 20 | ], 21 | rules: { 22 | indent: [2, 4] 23 | } 24 | } -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | libs/**/* -linguist-detectable 2 | public/amrnb.min.js -linguist-detectable 3 | public/silksdk.js -linguist-detectable 4 | public/silksdk.wasm -linguist-detectable -------------------------------------------------------------------------------- /.github/workflows/gh-page.yml: -------------------------------------------------------------------------------- 1 | name: Build and Deploy 2 | on: [push] 3 | jobs: 4 | build-and-deploy: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - name: Checkout 🛎️ 8 | uses: actions/checkout@v2.3.1 # If you're using actions/checkout@v2 you must set persist-credentials to false in most cases for the deployment to work correctly. 9 | with: 10 | persist-credentials: false 11 | 12 | - name: Install and Build 🔧 # This example project is built using npm and outputs the result to the 'build' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built. 13 | run: | 14 | yarn 15 | yarn build 16 | 17 | - name: Deploy 🚀 18 | uses: JamesIves/github-pages-deploy-action@3.7.1 19 | with: 20 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 21 | BRANCH: gh-pages # The branch the action should deploy to. 22 | FOLDER: public # The folder the action should deploy. 23 | CLEAN: true # Automatically remove deleted files from the deploy branch -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | public/build 3 | .vscode 4 | *.log -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "typescript.tsdk": "node_modules\\typescript\\lib" 3 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OneUI 2 | 3 | A frontend tool to **debug** backend supporting [OneBot](https://github.com/howmanybots/onebot) protocol. 4 | 5 | [Live Demo (Nightly)](https://steve-xmh.github.io/oneui/index.html) 6 | 7 | # Contribution 8 | 9 | Any PR are welcomed. Feel free to make this tool better! 10 | 11 | # Licence 12 | 13 | This tool is using CC0 Public Licence, which means you can do anything without permission. 14 | 15 | ![CC0 - 1.0](https://i.creativecommons.org/p/zero/1.0/88x31.png) 16 | -------------------------------------------------------------------------------- /libs/oneui-audio/.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/ 2 | pkg/ 3 | node_modules 4 | -------------------------------------------------------------------------------- /libs/oneui-audio/README.md: -------------------------------------------------------------------------------- 1 | # OneUI Audio 2 | 3 | A WASM library to process audio file into which the browser can play. 4 | 5 | The silk sdk library comes from a clone of [kn007/silk-v3-decoder](https://github.com/kn007/silk-v3-decoder). 6 | 7 | # How is it work? 8 | 9 | We use emscripten to compile decoder to wasm and a js wrapper, then emscripten will provide a virtual filesystem for us to input file and take out the ourput. 10 | So we can set an output file and take the result from virtual filesystem. That's the way OneUI using. 11 | 12 | # Build 13 | 14 | Use Emscripten to build. Then the compiled js in `pkg/` need to be moved to `oneui/src/utils/silksdk.js` to work with OneUI. 15 | 16 | # Contribution 17 | 18 | Any PR are welcomed. Feel free to make this tool better! 19 | 20 | # Licence 21 | 22 | This library is using CC0 Public Licence, which means you can do anything without permission. 23 | 24 | ![CC0 - 1.0](https://i.creativecommons.org/p/zero/1.0/88x31.png) 25 | -------------------------------------------------------------------------------- /libs/oneui-audio/build.js: -------------------------------------------------------------------------------- 1 | const childproc = require('child_process') 2 | const fs = require('fs') 3 | const { resolve } = require('path') 4 | 5 | fs.rmSync(resolve(__dirname, 'pkg'), { recursive: true, force: true }) 6 | fs.mkdirSync(resolve(__dirname, 'pkg')) 7 | 8 | const args = [ 9 | 'emcc', 10 | '-Os', 11 | '--closure 1', 12 | '--pre-js=src/pre.js', 13 | '-s ENVIRONMENT=worker', 14 | '-s WASM=1', 15 | '-s STRICT_JS=0', 16 | '-s INVOKE_RUN=1', 17 | // '-s MODULARIZE=1', 18 | // '-s SINGLE_FILE=1', 19 | '-s USE_GLFW=0', 20 | '-s USE_SDL=0', 21 | '-s EXPORT_NAME=SilkSDK', 22 | // '-s EXPORT_ES6=1', 23 | '-s EXPORT_ALL=1', 24 | '-s ALLOW_MEMORY_GROWTH=1', 25 | '-s BUILD_AS_WORKER=1', 26 | `-s EXTRA_EXPORTED_RUNTIME_METHODS="['FS','callMain']"`, 27 | '-flto', 28 | '-I', 29 | 'src/interface', 30 | '-I', 31 | 'src/src', 32 | '-I', 33 | 'src/test', 34 | '-o', 35 | 'pkg/silksdk.js', 36 | ] 37 | 38 | for (const file of fs.readdirSync(resolve(__dirname, 'src/src'))) { 39 | if (file.endsWith('.c')) args.push('src/src/' + file) 40 | } 41 | 42 | args.push('src/test/Decoder.c') 43 | 44 | console.log('Compiling Silk SDK using command:') 45 | console.log(args.join(' ')) 46 | 47 | const result = childproc.spawnSync(args.join(' '), { 48 | cwd: __dirname, 49 | shell: true, 50 | stdio: 'pipe', 51 | encoding: 'utf8' 52 | }) 53 | 54 | if (result.status !== 0) { 55 | console.error(result.error) 56 | console.error(result.stderr) 57 | } 58 | 59 | process.exit(result.status) 60 | -------------------------------------------------------------------------------- /libs/oneui-audio/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "oneui-audio", 3 | "version": "1.0.0", 4 | "main": "pkg/silksdk.js", 5 | "types": "index.d.ts", 6 | "author": "Steve-xmh ", 7 | "description": "Decode SILKv3 audio on web.", 8 | "license": "CC0-1.0", 9 | "scripts": { 10 | "postinstall": "node build.js", 11 | "build": "node build.js" 12 | }, 13 | "dependencies": { 14 | "@types/emscripten": "^1.39.4", 15 | "emscripten": "^0.0.2-beta" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Silk SDK 3 | # 4 | # Copyright (c) 2012, Skype Limited 5 | # All rights reserved. 6 | # 7 | 8 | #Platform detection and settings 9 | 10 | BUILD_OS := $(shell uname | sed -e 's/^.*Darwin.*/MacOS-X/ ; s/^.*CYGWIN.*/Windows/') 11 | 12 | BUILD_ARCHITECTURE := $(shell uname -m | sed -e 's/i686/i386/') 13 | 14 | EXESUFFIX = 15 | LIBPREFIX = lib 16 | LIBSUFFIX = .a 17 | OBJSUFFIX = .o 18 | 19 | CC = $(TOOLCHAIN_PREFIX)gcc$(TOOLCHAIN_SUFFIX) 20 | CXX = $(TOOLCHAIN_PREFIX)g++$(TOOLCHAIN_SUFFIX) 21 | AR = $(TOOLCHAIN_PREFIX)ar 22 | RANLIB = $(TOOLCHAIN_PREFIX)ranlib 23 | CP = $(TOOLCHAIN_PREFIX)cp 24 | 25 | cppflags-from-defines = $(addprefix -D,$(1)) 26 | cppflags-from-includes = $(addprefix -I,$(1)) 27 | ldflags-from-ldlibdirs = $(addprefix -L,$(1)) 28 | ldlibs-from-libs = $(addprefix -l,$(1)) 29 | 30 | ifneq (,$(TARGET_CPU)) 31 | CFLAGS += -mcpu=$(TARGET_CPU) 32 | ifneq (,$(TARGET_TUNE)) 33 | CFLAGS += -mtune=$(TARGET_TUNE) 34 | else 35 | CFLAGS += -mtune=$(TARGET_CPU) 36 | endif 37 | endif 38 | ifneq (,$(TARGET_FPU)) 39 | CFLAGS += -mfpu=$(TARGET_FPU) 40 | endif 41 | ifneq (,$(TARGET_ARCH)) 42 | CFLAGS += -march=$(TARGET_ARCH) 43 | endif 44 | # Helper to make NEON testing easier, when using USE_NEON=yes do not set TARGET_CPU or TARGET_FPU 45 | ifeq (yes,$(USE_NEON)) 46 | CFLAGS += -mcpu=cortex-a8 -mfloat-abi=softfp -mfpu=neon 47 | endif 48 | 49 | 50 | CFLAGS += -Wall -enable-threads -O3 -w 51 | 52 | CFLAGS += $(call cppflags-from-defines,$(CDEFINES)) 53 | CFLAGS += $(call cppflags-from-defines,$(ADDED_DEFINES)) 54 | CFLAGS += $(call cppflags-from-includes,$(CINCLUDES)) 55 | LDFLAGS += $(call ldflags-from-ldlibdirs,$(LDLIBDIRS)) 56 | LDLIBS += $(call ldlibs-from-libs,$(LIBS)) 57 | 58 | COMPILE.c.cmdline = $(CC) -c $(CFLAGS) $(ADDED_CFLAGS) -o $@ $< 59 | COMPILE.S.cmdline = $(CC) -c $(CFLAGS) $(ADDED_CFLAGS) -o $@ $< 60 | COMPILE.cpp.cmdline = $(CXX) -c $(CFLAGS) $(ADDED_CFLAGS) -o $@ $< 61 | LINK.o = $(CXX) $(LDPREFLAGS) $(LDFLAGS) 62 | LINK.o.cmdline = $(LINK.o) $^ $(LDLIBS) -o $@$(EXESUFFIX) 63 | ARCHIVE.cmdline = $(AR) $(ARFLAGS) $@ $^ && $(RANLIB) $@ 64 | 65 | %$(OBJSUFFIX):%.c 66 | $(COMPILE.c.cmdline) 67 | 68 | %$(OBJSUFFIX):%.cpp 69 | $(COMPILE.cpp.cmdline) 70 | 71 | %$(OBJSUFFIX):%.S 72 | $(COMPILE.S.cmdline) 73 | 74 | # Directives 75 | 76 | CINCLUDES += interface src test 77 | 78 | # VPATH e.g. VPATH = src:../headers 79 | VPATH = ./ \ 80 | interface \ 81 | src \ 82 | test 83 | 84 | # Variable definitions 85 | LIB_NAME = SKP_SILK_SDK 86 | TARGET = $(LIBPREFIX)$(LIB_NAME)$(LIBSUFFIX) 87 | 88 | SRCS_C = $(wildcard src/*.c) 89 | ifneq (,$(TOOLCHAIN_PREFIX)) 90 | SRCS_S = $(wildcard src/*.S) 91 | OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(SRCS_C)) $(patsubst %.S,%$(OBJSUFFIX),$(SRCS_S)) 92 | else 93 | OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(SRCS_C)) 94 | endif 95 | 96 | ENCODER_SRCS_C = test/Encoder.c 97 | ENCODER_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(ENCODER_SRCS_C)) 98 | 99 | DECODER_SRCS_C = test/Decoder.c 100 | DECODER_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(DECODER_SRCS_C)) 101 | 102 | SIGNALCMP_SRCS_C = test/signalCompare.c 103 | SIGNALCMP_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(SIGNALCMP_SRCS_C)) 104 | 105 | LIBS = \ 106 | $(LIB_NAME) 107 | 108 | LDLIBDIRS = ./ 109 | 110 | # Rules 111 | default: all 112 | 113 | all: $(TARGET) encoder decoder 114 | 115 | lib: $(TARGET) 116 | 117 | $(TARGET): $(OBJS) 118 | $(ARCHIVE.cmdline) 119 | 120 | encoder$(EXESUFFIX): $(ENCODER_OBJS) 121 | $(LINK.o.cmdline) 122 | 123 | decoder$(EXESUFFIX): $(DECODER_OBJS) 124 | $(LINK.o.cmdline) 125 | 126 | signalcompare$(EXESUFFIX): $(SIGNALCMP_OBJS) 127 | $(LINK.o.cmdline) 128 | 129 | clean: 130 | $(RM) $(TARGET)* $(OBJS) $(ENCODER_OBJS) $(DECODER_OBJS) \ 131 | $(SIGNALCMP_OBJS) $(TEST_OBJS) \ 132 | encoder$(EXESUFFIX) decoder$(EXESUFFIX) signalcompare$(EXESUFFIX) 133 | 134 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/interface/SKP_Silk_errors.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifndef SKP_SILK_ERRORS_H 29 | #define SKP_SILK_ERRORS_H 30 | 31 | #ifdef __cplusplus 32 | extern "C" 33 | { 34 | #endif 35 | 36 | /******************/ 37 | /* Error messages */ 38 | /******************/ 39 | #define SKP_SILK_NO_ERROR 0 40 | 41 | /**************************/ 42 | /* Encoder error messages */ 43 | /**************************/ 44 | 45 | /* Input length is not a multiplum of 10 ms, or length is longer than the packet length */ 46 | #define SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES -1 47 | 48 | /* Sampling frequency not 8000, 12000, 16000 or 24000 Hertz */ 49 | #define SKP_SILK_ENC_FS_NOT_SUPPORTED -2 50 | 51 | /* Packet size not 20, 40, 60, 80 or 100 ms */ 52 | #define SKP_SILK_ENC_PACKET_SIZE_NOT_SUPPORTED -3 53 | 54 | /* Allocated payload buffer too short */ 55 | #define SKP_SILK_ENC_PAYLOAD_BUF_TOO_SHORT -4 56 | 57 | /* Loss rate not between 0 and 100 percent */ 58 | #define SKP_SILK_ENC_INVALID_LOSS_RATE -5 59 | 60 | /* Complexity setting not valid, use 0, 1 or 2 */ 61 | #define SKP_SILK_ENC_INVALID_COMPLEXITY_SETTING -6 62 | 63 | /* Inband FEC setting not valid, use 0 or 1 */ 64 | #define SKP_SILK_ENC_INVALID_INBAND_FEC_SETTING -7 65 | 66 | /* DTX setting not valid, use 0 or 1 */ 67 | #define SKP_SILK_ENC_INVALID_DTX_SETTING -8 68 | 69 | /* Internal encoder error */ 70 | #define SKP_SILK_ENC_INTERNAL_ERROR -9 71 | 72 | /**************************/ 73 | /* Decoder error messages */ 74 | /**************************/ 75 | 76 | /* Output sampling frequency lower than internal decoded sampling frequency */ 77 | #define SKP_SILK_DEC_INVALID_SAMPLING_FREQUENCY -10 78 | 79 | /* Payload size exceeded the maximum allowed 1024 bytes */ 80 | #define SKP_SILK_DEC_PAYLOAD_TOO_LARGE -11 81 | 82 | /* Payload has bit errors */ 83 | #define SKP_SILK_DEC_PAYLOAD_ERROR -12 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/pre.js: -------------------------------------------------------------------------------- 1 | Module['locateFile'] = function(path, scriptDirectory) { 2 | // /\.\.\/[^\/]*\/?/ 3 | return scriptDirectory + '../' + path 4 | } -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_A2NLSF_arm.S: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #if defined(__arm__) 29 | 30 | #include "SKP_Silk_AsmPreproc.h" 31 | #if EMBEDDED_ARM>=6 32 | 33 | VARDEF y32, r3 34 | VARDEF pn1, r4 35 | VARDEF pn2, r5 36 | VARDEF lo, r6 37 | VARDEF hi, r8 38 | .globl SYM(SKP_Silk_A2NLSF_eval_poly) 39 | SYM(SKP_Silk_A2NLSF_eval_poly): 40 | stmdb sp!, {r4-r8, fp, ip, lr} 41 | add fp, sp, #28 42 | add r0, r0, r2, lsl #2 43 | ldr y32, [r0], #-4 44 | tst r2, #1 45 | beq LR(1, f) 46 | ldr pn1, [r0], #-4 47 | sub r2, r2, #1 48 | mov r1, r1, lsl #4 49 | L(0) 50 | smull lo, hi, y32, r1 51 | subs r2, r2, #1 52 | add y32, pn1, hi, lsl #16 53 | ldr pn1, [r0], #-4 54 | add y32, y32, lo, lsr #16 55 | bgt LR(0, b) 56 | smull lo, hi, y32, r1 57 | add y32, pn1, hi, lsl #16 58 | add r0, y32, lo, lsr #16 59 | ldmia sp!, {r4-r8, fp, ip, pc} 60 | 61 | L(1)/*EVEN:*/ 62 | add r0, r0, #4 63 | ldmdb r0!, {pn1, pn2} 64 | sub r2, r2, #2 65 | mov r1, r1, lsl #4 66 | L(0) 67 | smull lo, hi, y32, r1 68 | subs r2, r2, #2 69 | add y32, pn2, hi, lsl #16 70 | add y32, y32, lo, lsr #16 71 | smull lo, hi, y32, r1 72 | add y32, pn1, hi, lsl #16 73 | ldmdb r0!, {pn1, pn2} 74 | add y32, y32, lo, lsr #16 75 | bgt LR(0, b) 76 | smull lo, hi, y32, r1 77 | add y32, pn2, hi, lsl #16 78 | add y32, y32, lo, lsr #16 79 | smull lo, hi, y32, r1 80 | add y32, pn1, hi, lsl #16 81 | add r0, y32, lo, lsr #16 82 | ldmia sp!, {r4-r8, fp, ip, pc} 83 | END 84 | #endif 85 | #endif 86 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_LBRR_reset.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_main.h" 29 | 30 | /* Resets LBRR buffer, used if packet size changes */ 31 | void SKP_Silk_LBRR_reset( 32 | SKP_Silk_encoder_state *psEncC /* I/O state */ 33 | ) 34 | { 35 | SKP_int i; 36 | 37 | for( i = 0; i < MAX_LBRR_DELAY; i++ ) { 38 | psEncC->LBRR_buffer[ i ].usage = SKP_SILK_NO_LBRR; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_LTP_scale_ctrl_FIX.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_main_FIX.h" 29 | 30 | #define NB_THRESHOLDS 11 31 | 32 | /* Table containing trained thresholds for LTP scaling */ 33 | static const SKP_int16 LTPScaleThresholds_Q15[ NB_THRESHOLDS ] = 34 | { 35 | 31129, 26214, 16384, 13107, 9830, 6554, 36 | 4915, 3276, 2621, 2458, 0 37 | }; 38 | 39 | void SKP_Silk_LTP_scale_ctrl_FIX( 40 | SKP_Silk_encoder_state_FIX *psEnc, /* I/O encoder state FIX */ 41 | SKP_Silk_encoder_control_FIX *psEncCtrl /* I/O encoder control FIX */ 42 | ) 43 | { 44 | SKP_int round_loss, frames_per_packet; 45 | SKP_int g_out_Q5, g_limit_Q15, thrld1_Q15, thrld2_Q15; 46 | 47 | /* 1st order high-pass filter */ 48 | psEnc->HPLTPredCodGain_Q7 = SKP_max_int( psEncCtrl->LTPredCodGain_Q7 - psEnc->prevLTPredCodGain_Q7, 0 ) 49 | + SKP_RSHIFT_ROUND( psEnc->HPLTPredCodGain_Q7, 1 ); 50 | 51 | psEnc->prevLTPredCodGain_Q7 = psEncCtrl->LTPredCodGain_Q7; 52 | 53 | /* combine input and filtered input */ 54 | g_out_Q5 = SKP_RSHIFT_ROUND( SKP_RSHIFT( psEncCtrl->LTPredCodGain_Q7, 1 ) + SKP_RSHIFT( psEnc->HPLTPredCodGain_Q7, 1 ), 3 ); 55 | g_limit_Q15 = SKP_Silk_sigm_Q15( g_out_Q5 - ( 3 << 5 ) ); 56 | 57 | /* Default is minimum scaling */ 58 | psEncCtrl->sCmn.LTP_scaleIndex = 0; 59 | 60 | /* Round the loss measure to whole pct */ 61 | round_loss = ( SKP_int )psEnc->sCmn.PacketLoss_perc; 62 | 63 | /* Only scale if first frame in packet 0% */ 64 | if( psEnc->sCmn.nFramesInPayloadBuf == 0 ) { 65 | 66 | frames_per_packet = SKP_DIV32_16( psEnc->sCmn.PacketSize_ms, FRAME_LENGTH_MS ); 67 | 68 | round_loss += frames_per_packet - 1; 69 | thrld1_Q15 = LTPScaleThresholds_Q15[ SKP_min_int( round_loss, NB_THRESHOLDS - 1 ) ]; 70 | thrld2_Q15 = LTPScaleThresholds_Q15[ SKP_min_int( round_loss + 1, NB_THRESHOLDS - 1 ) ]; 71 | 72 | if( g_limit_Q15 > thrld1_Q15 ) { 73 | /* Maximum scaling */ 74 | psEncCtrl->sCmn.LTP_scaleIndex = 2; 75 | } else if( g_limit_Q15 > thrld2_Q15 ) { 76 | /* Medium scaling */ 77 | psEncCtrl->sCmn.LTP_scaleIndex = 1; 78 | } 79 | } 80 | psEncCtrl->LTP_scale_Q14 = SKP_Silk_LTPScales_table_Q14[ psEncCtrl->sCmn.LTP_scaleIndex ]; 81 | } 82 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_NLSF2A_stable.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_main.h" 29 | 30 | /* Convert NLSF parameters to stable AR prediction filter coefficients */ 31 | void SKP_Silk_NLSF2A_stable( 32 | SKP_int16 pAR_Q12[ MAX_LPC_ORDER ], /* O Stabilized AR coefs [LPC_order] */ 33 | const SKP_int pNLSF[ MAX_LPC_ORDER ], /* I NLSF vector [LPC_order] */ 34 | const SKP_int LPC_order /* I LPC/LSF order */ 35 | ) 36 | { 37 | SKP_int i; 38 | SKP_int32 invGain_Q30; 39 | 40 | SKP_Silk_NLSF2A( pAR_Q12, pNLSF, LPC_order ); 41 | 42 | /* Ensure stable LPCs */ 43 | for( i = 0; i < MAX_LPC_STABILIZE_ITERATIONS; i++ ) { 44 | if( SKP_Silk_LPC_inverse_pred_gain( &invGain_Q30, pAR_Q12, LPC_order ) == 1 ) { 45 | SKP_Silk_bwexpander( pAR_Q12, LPC_order, 65536 - SKP_SMULBB( 10 + i, i ) ); /* 10_Q16 = 0.00015 */ 46 | } else { 47 | break; 48 | } 49 | } 50 | 51 | /* Reached the last iteration */ 52 | if( i == MAX_LPC_STABILIZE_ITERATIONS ) { 53 | SKP_assert( 0 ); 54 | for( i = 0; i < LPC_order; i++ ) { 55 | pAR_Q12[ i ] = 0; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_NLSF_VQ_rate_distortion_FIX.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_main_FIX.h" 29 | 30 | /* Rate-Distortion calculations for multiple input data vectors */ 31 | void SKP_Silk_NLSF_VQ_rate_distortion_FIX( 32 | SKP_int32 *pRD_Q20, /* O Rate-distortion values [psNLSF_CBS->nVectors*N] */ 33 | const SKP_Silk_NLSF_CBS *psNLSF_CBS, /* I NLSF codebook stage struct */ 34 | const SKP_int *in_Q15, /* I Input vectors to be quantized */ 35 | const SKP_int *w_Q6, /* I Weight vector */ 36 | const SKP_int32 *rate_acc_Q5, /* I Accumulated rates from previous stage */ 37 | const SKP_int mu_Q15, /* I Weight between weighted error and rate */ 38 | const SKP_int N, /* I Number of input vectors to be quantized */ 39 | const SKP_int LPC_order /* I LPC order */ 40 | ) 41 | { 42 | SKP_int i, n; 43 | SKP_int32 *pRD_vec_Q20; 44 | 45 | /* Compute weighted quantization errors for all input vectors over one codebook stage */ 46 | SKP_Silk_NLSF_VQ_sum_error_FIX( pRD_Q20, in_Q15, w_Q6, psNLSF_CBS->CB_NLSF_Q15, 47 | N, psNLSF_CBS->nVectors, LPC_order ); 48 | 49 | /* Loop over input vectors */ 50 | pRD_vec_Q20 = pRD_Q20; 51 | for( n = 0; n < N; n++ ) { 52 | /* Add rate cost to error for each codebook vector */ 53 | for( i = 0; i < psNLSF_CBS->nVectors; i++ ) { 54 | SKP_assert( rate_acc_Q5[ n ] + psNLSF_CBS->Rates_Q5[ i ] >= 0 ); 55 | SKP_assert( rate_acc_Q5[ n ] + psNLSF_CBS->Rates_Q5[ i ] <= SKP_int16_MAX ); 56 | pRD_vec_Q20[ i ] = SKP_SMLABB( pRD_vec_Q20[ i ], rate_acc_Q5[ n ] + psNLSF_CBS->Rates_Q5[ i ], mu_Q15 ); 57 | SKP_assert( pRD_vec_Q20[ i ] >= 0 ); 58 | } 59 | pRD_vec_Q20 += psNLSF_CBS->nVectors; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_allpass_int_arm.S: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #if defined(__arm__) 29 | 30 | #include "SKP_Silk_AsmPreproc.h" 31 | 32 | #if EMBEDDED_ARM >= 5 33 | VARDEF A, r2 34 | VARDEF len, r4 35 | VARDEF S00, r5 36 | VARDEF ink1, r6 37 | VARDEF ink2, r8 38 | VARDEF Y2, sb 39 | VARDEF outk1, sl 40 | VARDEF outk2, ip 41 | 42 | .globl SYM(SKP_Silk_allpass_int) 43 | SYM(SKP_Silk_allpass_int): 44 | stmdb sp!, {r4-r10, fp, ip, lr} 45 | add fp, sp, #36 46 | .set len_offset, 40 47 | ldr len, [sp, #len_offset] 48 | ldr S00, [r1] 49 | movs A, A, lsl #17 50 | sub len, len, #1 51 | ldmia r0!, {ink1,ink2} 52 | bge LR(1, f)/*AgeZero*/ 53 | L(0) 54 | sub Y2, ink1, S00 55 | smlawt outk1, Y2, A, ink1 56 | add S00, Y2, outk1 57 | subs len, len, #2 58 | sub Y2, ink2, S00 59 | smlawt outk2, Y2, A, ink2 60 | #ifdef _WINRT 61 | ble LR(3, f) 62 | ldmia r0!, {ink1,ink2} 63 | L(3) 64 | #else 65 | ldmgtia r0!, {ink1,ink2} 66 | #endif 67 | add S00, Y2, outk2 68 | stmia r3!, {outk1, outk2} 69 | bgt LR(0, b) 70 | #ifdef _WINRT 71 | bne LR(2, f) 72 | ldr ink1, [r0], #4 73 | sub Y2, ink1, S00 74 | smlawt outk1, Y2, A, ink1 75 | add S00, Y2, outk1 76 | str outk1, [r3] 77 | L(2) 78 | #else 79 | ldreq ink1, [r0], #4 80 | subeq Y2, ink1, S00 81 | smlawteq outk1, Y2, A, ink1 82 | addeq S00, Y2, outk1 83 | streq outk1, [r3] 84 | #endif 85 | str S00, [r1] 86 | ldmia sp!, {r4-r10, fp, ip, pc} 87 | 88 | L(1)/*AgeZero:*/ 89 | sub Y2, ink1, S00 90 | smlawt outk1, Y2, A, S00 91 | add S00, Y2, outk1 92 | subs len, len, #2 93 | sub Y2, ink2, S00 94 | smlawt outk2, Y2, A, S00 95 | #ifdef _WINRT 96 | ble LR(3, f) 97 | ldmia r0!, {ink1,ink2} 98 | L(3) 99 | #else 100 | ldmgtia r0!, {ink1,ink2} 101 | #endif 102 | add S00, Y2, outk2 103 | stmia r3!, {outk1, outk2} 104 | bgt LR(1, b) 105 | #ifdef _WINRT 106 | bne LR(2, f) 107 | ldr ink1, [r0], #4 108 | sub Y2, ink1, S00 109 | smlawt outk1, Y2, A, S00 110 | add S00, Y2, outk1 111 | str outk1, [r3] 112 | L(2) 113 | #else 114 | ldreq ink1, [r0], #4 115 | subeq Y2, ink1, S00 116 | smlawteq outk1, Y2, A, S00 117 | addeq S00, Y2, outk1 118 | streq outk1, [r3] 119 | #endif 120 | str S00, [r1] 121 | ldmia sp!, {r4-r10, fp, ip, pc} 122 | END 123 | #endif 124 | #endif 125 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_array_maxabs.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | /* * 29 | * SKP_Silk_int16_array_maxabs.c * 30 | * * 31 | * Function that returns the maximum absolut value of * 32 | * the input vector * 33 | * * 34 | * Copyright 2006 (c), Skype Limited * 35 | * Date: 060221 * 36 | * */ 37 | #include "SKP_Silk_SigProc_FIX.h" 38 | 39 | /* Function that returns the maximum absolut value of the input vector */ 40 | #if (EMBEDDED_ARM<4) 41 | SKP_int16 SKP_Silk_int16_array_maxabs( /* O Maximum absolute value, max: 2^15-1 */ 42 | const SKP_int16 *vec, /* I Input vector [len] */ 43 | const SKP_int32 len /* I Length of input vector */ 44 | ) 45 | { 46 | SKP_int32 max = 0, i, lvl = 0, ind; 47 | if( len == 0 ) return 0; 48 | 49 | ind = len - 1; 50 | max = SKP_SMULBB( vec[ ind ], vec[ ind ] ); 51 | for( i = len - 2; i >= 0; i-- ) { 52 | lvl = SKP_SMULBB( vec[ i ], vec[ i ] ); 53 | if( lvl > max ) { 54 | max = lvl; 55 | ind = i; 56 | } 57 | } 58 | 59 | /* Do not return 32768, as it will not fit in an int16 so may lead to problems later on */ 60 | if( max >= 1073676289 ) { // (2^15-1)^2 = 1073676289 61 | return( SKP_int16_MAX ); 62 | } else { 63 | if( vec[ ind ] < 0 ) { 64 | return( -vec[ ind ] ); 65 | } else { 66 | return( vec[ ind ] ); 67 | } 68 | } 69 | } 70 | #endif 71 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_biquad.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | /* * 29 | * SKP_Silk_biquad.c * 30 | * * 31 | * Second order ARMA filter * 32 | * Can handle slowly varying filter coefficients * 33 | * * 34 | * Copyright 2006 (c), Skype Limited * 35 | * Date: 060221 * 36 | * */ 37 | #include "SKP_Silk_SigProc_FIX.h" 38 | 39 | /* Second order ARMA filter */ 40 | /* Can handle slowly varying filter coefficients */ 41 | void SKP_Silk_biquad( 42 | const SKP_int16 *in, /* I: input signal */ 43 | const SKP_int16 *B, /* I: MA coefficients, Q13 [3] */ 44 | const SKP_int16 *A, /* I: AR coefficients, Q13 [2] */ 45 | SKP_int32 *S, /* I/O: state vector [2] */ 46 | SKP_int16 *out, /* O: output signal */ 47 | const SKP_int32 len /* I: signal length */ 48 | ) 49 | { 50 | SKP_int k, in16; 51 | SKP_int32 A0_neg, A1_neg, S0, S1, out32, tmp32; 52 | 53 | S0 = S[ 0 ]; 54 | S1 = S[ 1 ]; 55 | A0_neg = -A[ 0 ]; 56 | A1_neg = -A[ 1 ]; 57 | for( k = 0; k < len; k++ ) { 58 | /* S[ 0 ], S[ 1 ]: Q13 */ 59 | in16 = in[ k ]; 60 | out32 = SKP_SMLABB( S0, in16, B[ 0 ] ); 61 | 62 | S0 = SKP_SMLABB( S1, in16, B[ 1 ] ); 63 | S0 += SKP_LSHIFT( SKP_SMULWB( out32, A0_neg ), 3 ); 64 | 65 | S1 = SKP_LSHIFT( SKP_SMULWB( out32, A1_neg ), 3 ); 66 | S1 = SKP_SMLABB( S1, in16, B[ 2 ] ); 67 | tmp32 = SKP_RSHIFT_ROUND( out32, 13 ) + 1; 68 | out[ k ] = (SKP_int16)SKP_SAT16( tmp32 ); 69 | } 70 | S[ 0 ] = S0; 71 | S[ 1 ] = S1; 72 | } 73 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_bwexpander.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_SigProc_FIX.h" 29 | 30 | /* Chirp (bandwidth expand) LP AR filter */ 31 | void SKP_Silk_bwexpander( 32 | SKP_int16 *ar, /* I/O AR filter to be expanded (without leading 1) */ 33 | const SKP_int d, /* I Length of ar */ 34 | SKP_int32 chirp_Q16 /* I Chirp factor (typically in the range 0 to 1) */ 35 | ) 36 | { 37 | SKP_int i; 38 | SKP_int32 chirp_minus_one_Q16; 39 | 40 | chirp_minus_one_Q16 = chirp_Q16 - 65536; 41 | 42 | /* NB: Dont use SKP_SMULWB, instead of SKP_RSHIFT_ROUND( SKP_MUL() , 16 ), below. */ 43 | /* Bias in SKP_SMULWB can lead to unstable filters */ 44 | for( i = 0; i < d - 1; i++ ) { 45 | ar[ i ] = (SKP_int16)SKP_RSHIFT_ROUND( SKP_MUL( chirp_Q16, ar[ i ] ), 16 ); 46 | chirp_Q16 += SKP_RSHIFT_ROUND( SKP_MUL( chirp_Q16, chirp_minus_one_Q16 ), 16 ); 47 | } 48 | ar[ d - 1 ] = (SKP_int16)SKP_RSHIFT_ROUND( SKP_MUL( chirp_Q16, ar[ d - 1 ] ), 16 ); 49 | } 50 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_bwexpander_32.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_SigProc_FIX.h" 29 | 30 | /* Chirp (bandwidth expand) LP AR filter */ 31 | void SKP_Silk_bwexpander_32( 32 | SKP_int32 *ar, /* I/O AR filter to be expanded (without leading 1) */ 33 | const SKP_int d, /* I Length of ar */ 34 | SKP_int32 chirp_Q16 /* I Chirp factor in Q16 */ 35 | ) 36 | { 37 | SKP_int i; 38 | SKP_int32 tmp_chirp_Q16; 39 | 40 | tmp_chirp_Q16 = chirp_Q16; 41 | for( i = 0; i < d - 1; i++ ) { 42 | ar[ i ] = SKP_SMULWW( ar[ i ], tmp_chirp_Q16 ); 43 | tmp_chirp_Q16 = SKP_SMULWW( chirp_Q16, tmp_chirp_Q16 ); 44 | } 45 | ar[ d - 1 ] = SKP_SMULWW( ar[ d - 1 ], tmp_chirp_Q16 ); 46 | } 47 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_clz_arm.S: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #if defined(__arm__) 29 | 30 | #include "SKP_Silk_AsmPreproc.h" 31 | #if (EMBEDDED_ARM>0) && (EMBEDDED_ARM<5) 32 | 33 | .globl SYM(SKP_Silk_CLZ16) 34 | .globl SYM(SKP_Silk_CLZ32) 35 | 36 | SYM(SKP_Silk_CLZ16): 37 | str lr, [sp, #-4]! 38 | 39 | mov r2, r0 40 | mov r0, #0 41 | ands r1, r2, #0xF000 42 | movne r1, r2, asr #12 43 | bne 0f 44 | add r0, r0, #4 45 | ands r1, r2, #0xF00 46 | movne r1, r2, asr #8 47 | bne 0f 48 | add r0, r0, #4 49 | ands r1, r2, #0xF0 50 | movne r1, r2, asr #4 51 | bne 0f 52 | add r0, r0, #4 53 | mov r1, r2 54 | 0: 55 | ands r2, r1, #0x8 56 | bne 1f 57 | add r0, r0, #1 58 | ands r2, r1, #0x4 59 | bne 1f 60 | add r0, r0, #1 61 | ands r2, r1, #0x2 62 | bne 1f 63 | add r0, r0, #1 64 | ands r2, r1, #0x1 65 | bne 1f 66 | add r0, r0, #1 67 | 1: 68 | ldr pc, [sp], #4 69 | 70 | SYM(SKP_Silk_CLZ32): 71 | 72 | str lr, [sp, #-4]! 73 | 74 | mov r2, r0 75 | mov r0, #0 76 | ands r1, r2, #0xF0000000 77 | movne r1, r2, asr #28 78 | bne 0f 79 | add r0, r0, #4 80 | ands r1, r2, #0xF000000 81 | movne r1, r2, asr #24 82 | bne 0f 83 | add r0, r0, #4 84 | ands r1, r2, #0xF00000 85 | movne r1, r2, asr #20 86 | bne 0f 87 | add r0, r0, #4 88 | ands r1, r2, #0xF0000 89 | movne r1, r2, asr #16 90 | bne 0f 91 | add r0, r0, #4 92 | ands r1, r2, #0xF000 93 | movne r1, r2, asr #12 94 | bne 0f 95 | add r0, r0, #4 96 | ands r1, r2, #0xF00 97 | movne r1, r2, asr #8 98 | bne 0f 99 | add r0, r0, #4 100 | ands r1, r2, #0xF0 101 | movne r1, r2, asr #4 102 | bne 0f 103 | add r0, r0, #4 104 | mov r1, r2 105 | 0: 106 | ands r2, r1, #0x8 107 | bne 1f 108 | add r0, r0, #1 109 | ands r2, r1, #0x4 110 | bne 1f 111 | add r0, r0, #1 112 | ands r2, r1, #0x2 113 | bne 1f 114 | add r0, r0, #1 115 | ands r2, r1, #0x1 116 | bne 1f 117 | add r0, r0, #1 118 | 1: 119 | ldr pc, [sp], #4 120 | 121 | #endif 122 | #endif 123 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_common_pitch_est_defines.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifndef SIGPROC_COMMON_PITCH_EST_DEFINES_H 29 | #define SIGPROC_COMMON_PITCH_EST_DEFINES_H 30 | 31 | #include "SKP_Silk_SigProc_FIX.h" 32 | 33 | /************************************************************/ 34 | /* Definitions For Fix pitch estimator */ 35 | /************************************************************/ 36 | 37 | #define PITCH_EST_MAX_FS_KHZ 24 /* Maximum sampling frequency used */ 38 | 39 | #define PITCH_EST_FRAME_LENGTH_MS 40 /* 40 ms */ 40 | 41 | #define PITCH_EST_MAX_FRAME_LENGTH (PITCH_EST_FRAME_LENGTH_MS * PITCH_EST_MAX_FS_KHZ) 42 | #define PITCH_EST_MAX_FRAME_LENGTH_ST_1 (PITCH_EST_MAX_FRAME_LENGTH >> 2) 43 | #define PITCH_EST_MAX_FRAME_LENGTH_ST_2 (PITCH_EST_MAX_FRAME_LENGTH >> 1) 44 | #define PITCH_EST_MAX_SF_FRAME_LENGTH (PITCH_EST_SUB_FRAME * PITCH_EST_MAX_FS_KHZ) 45 | 46 | #define PITCH_EST_MAX_LAG_MS 18 /* 18 ms -> 56 Hz */ 47 | #define PITCH_EST_MIN_LAG_MS 2 /* 2 ms -> 500 Hz */ 48 | #define PITCH_EST_MAX_LAG (PITCH_EST_MAX_LAG_MS * PITCH_EST_MAX_FS_KHZ) 49 | #define PITCH_EST_MIN_LAG (PITCH_EST_MIN_LAG_MS * PITCH_EST_MAX_FS_KHZ) 50 | 51 | #define PITCH_EST_NB_SUBFR 4 52 | 53 | #define PITCH_EST_D_SRCH_LENGTH 24 54 | 55 | #define PITCH_EST_MAX_DECIMATE_STATE_LENGTH 7 56 | 57 | #define PITCH_EST_NB_STAGE3_LAGS 5 58 | 59 | #define PITCH_EST_NB_CBKS_STAGE2 3 60 | #define PITCH_EST_NB_CBKS_STAGE2_EXT 11 61 | 62 | #define PITCH_EST_CB_mn2 1 63 | #define PITCH_EST_CB_mx2 2 64 | 65 | #define PITCH_EST_NB_CBKS_STAGE3_MAX 34 66 | #define PITCH_EST_NB_CBKS_STAGE3_MID 24 67 | #define PITCH_EST_NB_CBKS_STAGE3_MIN 16 68 | 69 | extern const SKP_int16 SKP_Silk_CB_lags_stage2[PITCH_EST_NB_SUBFR][PITCH_EST_NB_CBKS_STAGE2_EXT]; 70 | extern const SKP_int16 SKP_Silk_CB_lags_stage3[PITCH_EST_NB_SUBFR][PITCH_EST_NB_CBKS_STAGE3_MAX]; 71 | extern const SKP_int16 SKP_Silk_Lag_range_stage3[ SKP_Silk_PITCH_EST_MAX_COMPLEX + 1 ] [ PITCH_EST_NB_SUBFR ][ 2 ]; 72 | extern const SKP_int16 SKP_Silk_cbk_sizes_stage3[ SKP_Silk_PITCH_EST_MAX_COMPLEX + 1 ]; 73 | extern const SKP_int16 SKP_Silk_cbk_offsets_stage3[ SKP_Silk_PITCH_EST_MAX_COMPLEX + 1 ]; 74 | 75 | #endif 76 | 77 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_create_init_destroy.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_main.h" 29 | 30 | 31 | /************************/ 32 | /* Init Decoder State */ 33 | /************************/ 34 | SKP_int SKP_Silk_init_decoder( 35 | SKP_Silk_decoder_state *psDec /* I/O Decoder state pointer */ 36 | ) 37 | { 38 | SKP_memset( psDec, 0, sizeof( SKP_Silk_decoder_state ) ); 39 | /* Set sampling rate to 24 kHz, and init non-zero values */ 40 | SKP_Silk_decoder_set_fs( psDec, 24 ); 41 | 42 | /* Used to deactivate e.g. LSF interpolation and fluctuation reduction */ 43 | psDec->first_frame_after_reset = 1; 44 | psDec->prev_inv_gain_Q16 = 65536; 45 | 46 | /* Reset CNG state */ 47 | SKP_Silk_CNG_Reset( psDec ); 48 | 49 | SKP_Silk_PLC_Reset( psDec ); 50 | 51 | return(0); 52 | } 53 | 54 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_decode_pitch.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | /*********************************************************** 29 | * Pitch analyser function 30 | ********************************************************** */ 31 | #include "SKP_Silk_SigProc_FIX.h" 32 | #include "SKP_Silk_common_pitch_est_defines.h" 33 | 34 | void SKP_Silk_decode_pitch( 35 | SKP_int lagIndex, /* I */ 36 | SKP_int contourIndex, /* O */ 37 | SKP_int pitch_lags[], /* O 4 pitch values */ 38 | SKP_int Fs_kHz /* I sampling frequency (kHz) */ 39 | ) 40 | { 41 | SKP_int lag, i, min_lag; 42 | 43 | min_lag = SKP_SMULBB( PITCH_EST_MIN_LAG_MS, Fs_kHz ); 44 | 45 | /* Only for 24 / 16 kHz version for now */ 46 | lag = min_lag + lagIndex; 47 | if( Fs_kHz == 8 ) { 48 | /* Only a small codebook for 8 khz */ 49 | for( i = 0; i < PITCH_EST_NB_SUBFR; i++ ) { 50 | pitch_lags[ i ] = lag + SKP_Silk_CB_lags_stage2[ i ][ contourIndex ]; 51 | } 52 | } else { 53 | for( i = 0; i < PITCH_EST_NB_SUBFR; i++ ) { 54 | pitch_lags[ i ] = lag + SKP_Silk_CB_lags_stage3[ i ][ contourIndex ]; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_div_oabi.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_typedef.h" 29 | 30 | SKP_int32 SKP_DIV32_arm( SKP_int32 a32, SKP_int32 b32 ) { 31 | return ( ( SKP_int32 )( ( a32 ) / ( b32 ) ) ); 32 | } 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_init_encoder_FIX.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_main_FIX.h" 29 | 30 | /*********************************/ 31 | /* Initialize Silk Encoder state */ 32 | /*********************************/ 33 | SKP_int SKP_Silk_init_encoder_FIX( 34 | SKP_Silk_encoder_state_FIX *psEnc /* I/O Pointer to Silk FIX encoder state */ 35 | ) { 36 | SKP_int ret = 0; 37 | /* Clear the entire encoder state */ 38 | SKP_memset( psEnc, 0, sizeof( SKP_Silk_encoder_state_FIX ) ); 39 | 40 | #if HIGH_PASS_INPUT 41 | psEnc->variable_HP_smth1_Q15 = 200844; /* = SKP_Silk_log2(70)_Q0; */ 42 | psEnc->variable_HP_smth2_Q15 = 200844; /* = SKP_Silk_log2(70)_Q0; */ 43 | #endif 44 | 45 | /* Used to deactivate e.g. LSF interpolation and fluctuation reduction */ 46 | psEnc->sCmn.first_frame_after_reset = 1; 47 | 48 | /* Initialize Silk VAD */ 49 | ret += SKP_Silk_VAD_Init( &psEnc->sCmn.sVAD ); 50 | 51 | /* Initialize NSQ */ 52 | psEnc->sCmn.sNSQ.prev_inv_gain_Q16 = 65536; 53 | psEnc->sCmn.sNSQ_LBRR.prev_inv_gain_Q16 = 65536; 54 | 55 | return( ret ); 56 | } 57 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_inner_prod_aligned.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | /* * 29 | * SKP_Silk_inner_prod_aligned.c * 30 | * * 31 | * * 32 | * Copyright 2008-2010 (c), Skype Limited * 33 | * Date: 080601 * 34 | * */ 35 | #include "SKP_Silk_SigProc_FIX.h" 36 | 37 | /* sum= for(i=0;i6, memory access can be reduced by half. */ 42 | 43 | #if (EMBEDDED_ARM<5) 44 | SKP_int32 SKP_Silk_inner_prod_aligned( 45 | const SKP_int16* const inVec1, /* I input vector 1 */ 46 | const SKP_int16* const inVec2, /* I input vector 2 */ 47 | const SKP_int len /* I vector lengths */ 48 | ) 49 | { 50 | SKP_int i; 51 | SKP_int32 sum = 0; 52 | for( i = 0; i < len; i++ ) { 53 | sum = SKP_SMLABB( sum, inVec1[ i ], inVec2[ i ] ); 54 | } 55 | return sum; 56 | } 57 | #endif 58 | 59 | #if (EMBEDDED_ARM<5) 60 | SKP_int64 SKP_Silk_inner_prod16_aligned_64( 61 | const SKP_int16 *inVec1, /* I input vector 1 */ 62 | const SKP_int16 *inVec2, /* I input vector 2 */ 63 | const SKP_int len /* I vector lengths */ 64 | ) 65 | { 66 | SKP_int i; 67 | SKP_int64 sum = 0; 68 | for( i = 0; i < len; i++ ) { 69 | sum = SKP_SMLALBB( sum, inVec1[ i ], inVec2[ i ] ); 70 | } 71 | return sum; 72 | } 73 | #endif 74 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_interpolate.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_main.h" 29 | 30 | /* Interpolate two vectors */ 31 | void SKP_Silk_interpolate( 32 | SKP_int xi[ MAX_LPC_ORDER ], /* O interpolated vector */ 33 | const SKP_int x0[ MAX_LPC_ORDER ], /* I first vector */ 34 | const SKP_int x1[ MAX_LPC_ORDER ], /* I second vector */ 35 | const SKP_int ifact_Q2, /* I interp. factor, weight on 2nd vector */ 36 | const SKP_int d /* I number of parameters */ 37 | ) 38 | { 39 | SKP_int i; 40 | 41 | SKP_assert( ifact_Q2 >= 0 ); 42 | SKP_assert( ifact_Q2 <= ( 1 << 2 ) ); 43 | 44 | for( i = 0; i < d; i++ ) { 45 | xi[ i ] = ( SKP_int )( ( SKP_int32 )x0[ i ] + SKP_RSHIFT( SKP_MUL( ( SKP_int32 )x1[ i ] - ( SKP_int32 )x0[ i ], ifact_Q2 ), 2 ) ); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_k2a.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | /* * 29 | * SKP_Silk_k2a.c * 30 | * * 31 | * Step up function, converts reflection coefficients to prediction * 32 | * coefficients * 33 | * * 34 | * Copyright 2008 (c), Skype Limited * 35 | * Date: 080103 * 36 | * */ 37 | #include "SKP_Silk_SigProc_FIX.h" 38 | 39 | /* Step up function, converts reflection coefficients to prediction coefficients */ 40 | void SKP_Silk_k2a( 41 | SKP_int32 *A_Q24, /* O: Prediction coefficients [order] Q24 */ 42 | const SKP_int16 *rc_Q15, /* I: Reflection coefficients [order] Q15 */ 43 | const SKP_int32 order /* I: Prediction order */ 44 | ) 45 | { 46 | SKP_int k, n; 47 | SKP_int32 Atmp[ SKP_Silk_MAX_ORDER_LPC ]; 48 | 49 | for( k = 0; k < order; k++ ) { 50 | for( n = 0; n < k; n++ ) { 51 | Atmp[ n ] = A_Q24[ n ]; 52 | } 53 | for( n = 0; n < k; n++ ) { 54 | A_Q24[ n ] = SKP_SMLAWB( A_Q24[ n ], SKP_LSHIFT( Atmp[ k - n - 1 ], 1 ), rc_Q15[ k ] ); 55 | } 56 | A_Q24[ k ] = -SKP_LSHIFT( (SKP_int32)rc_Q15[ k ], 9 ); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_k2a_Q16.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | /* * 29 | * SKP_Silk_k2a.c * 30 | * * 31 | * Step up function, converts reflection coefficients to prediction * 32 | * coefficients * 33 | * * 34 | * Copyright 2008 (c), Skype Limited * 35 | * Date: 080103 * 36 | * */ 37 | #include "SKP_Silk_SigProc_FIX.h" 38 | 39 | /* Step up function, converts reflection coefficients to prediction coefficients */ 40 | void SKP_Silk_k2a_Q16( 41 | SKP_int32 *A_Q24, /* O: Prediction coefficients [order] Q24 */ 42 | const SKP_int32 *rc_Q16, /* I: Reflection coefficients [order] Q16 */ 43 | const SKP_int32 order /* I: Prediction order */ 44 | ) 45 | { 46 | SKP_int k, n; 47 | SKP_int32 Atmp[ SKP_Silk_MAX_ORDER_LPC ]; 48 | 49 | for( k = 0; k < order; k++ ) { 50 | for( n = 0; n < k; n++ ) { 51 | Atmp[ n ] = A_Q24[ n ]; 52 | } 53 | for( n = 0; n < k; n++ ) { 54 | A_Q24[ n ] = SKP_SMLAWW( A_Q24[ n ], Atmp[ k - n - 1 ], rc_Q16[ k ] ); 55 | } 56 | A_Q24[ k ] = -SKP_LSHIFT( rc_Q16[ k ], 8 ); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_lin2log.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | /* * 29 | * SKP_Silk_lin2log.c * 30 | * * 31 | * Convert input to a log scale * 32 | * Approximation of 128 * log2() * 33 | * * 34 | * Copyright 2006 (c), Skype Limited * 35 | * Date: 060221 * 36 | * */ 37 | #include "SKP_Silk_SigProc_FIX.h" 38 | #if EMBEDDED_ARM<4 39 | /* Approximation of 128 * log2() (very close inverse of approx 2^() below) */ 40 | /* Convert input to a log scale */ 41 | SKP_int32 SKP_Silk_lin2log( const SKP_int32 inLin ) /* I: Input in linear scale */ 42 | { 43 | SKP_int32 lz, frac_Q7; 44 | 45 | SKP_Silk_CLZ_FRAC( inLin, &lz, &frac_Q7 ); 46 | 47 | /* Piece-wise parabolic approximation */ 48 | return( SKP_LSHIFT( 31 - lz, 7 ) + SKP_SMLAWB( frac_Q7, SKP_MUL( frac_Q7, 128 - frac_Q7 ), 179 ) ); 49 | } 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_log2lin.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | /* * 29 | * SKP_Silk_log2lin.c * 30 | * * 31 | * Convert input to a linear scale * 32 | * * 33 | * Copyright 2006 (c), Skype Limited * 34 | * Date: 060221 * 35 | * */ 36 | #include "SKP_Silk_SigProc_FIX.h" 37 | 38 | /* Approximation of 2^() (very close inverse of SKP_Silk_lin2log()) */ 39 | /* Convert input to a linear scale */ 40 | SKP_int32 SKP_Silk_log2lin( const SKP_int32 inLog_Q7 ) /* I: Input on log scale */ 41 | { 42 | SKP_int32 out, frac_Q7; 43 | 44 | if( inLog_Q7 < 0 ) { 45 | return( 0 ); 46 | } else if( inLog_Q7 >= ( 31 << 7 ) ) { 47 | /* Saturate, and prevent wrap-around */ 48 | return( SKP_int32_MAX ); 49 | } 50 | 51 | out = SKP_LSHIFT( 1, SKP_RSHIFT( inLog_Q7, 7 ) ); 52 | frac_Q7 = inLog_Q7 & 0x7F; 53 | if( inLog_Q7 < 2048 ) { 54 | /* Piece-wise parabolic approximation */ 55 | out = SKP_ADD_RSHIFT( out, SKP_MUL( out, SKP_SMLAWB( frac_Q7, SKP_MUL( frac_Q7, 128 - frac_Q7 ), -174 ) ), 7 ); 56 | } else { 57 | /* Piece-wise parabolic approximation */ 58 | out = SKP_MLA( out, SKP_RSHIFT( out, 7 ), SKP_SMLAWB( frac_Q7, SKP_MUL( frac_Q7, 128 - frac_Q7 ), -174 ) ); 59 | } 60 | return out; 61 | } 62 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_pitch_est_defines.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifndef SIGPROCFIX_PITCH_EST_DEFINES_H 29 | #define SIGPROCFIX_PITCH_EST_DEFINES_H 30 | 31 | /************************************************************/ 32 | /* Definitions For Fix pitch estimator */ 33 | /************************************************************/ 34 | 35 | #define PITCH_EST_SHORTLAG_BIAS_Q15 6554 /* 0.2f. for logarithmic weighting */ 36 | #define PITCH_EST_PREVLAG_BIAS_Q15 6554 /* Prev lag bias */ 37 | #define PITCH_EST_FLATCONTOUR_BIAS_Q20 52429 /* 0.05f */ 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_pitch_est_tables.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_typedef.h" 29 | #include "SKP_Silk_common_pitch_est_defines.h" 30 | 31 | /********************************************************/ 32 | /* Auto Generated File from generate_pitch_est_tables.m */ 33 | /********************************************************/ 34 | 35 | const SKP_int16 SKP_Silk_CB_lags_stage2[PITCH_EST_NB_SUBFR][PITCH_EST_NB_CBKS_STAGE2_EXT] = 36 | { 37 | {0, 2,-1,-1,-1, 0, 0, 1, 1, 0, 1}, 38 | {0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0}, 39 | {0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0}, 40 | {0,-1, 2, 1, 0, 1, 1, 0, 0,-1,-1} 41 | }; 42 | 43 | const SKP_int16 SKP_Silk_CB_lags_stage3[PITCH_EST_NB_SUBFR][PITCH_EST_NB_CBKS_STAGE3_MAX] = 44 | { 45 | {-9,-7,-6,-5,-5,-4,-4,-3,-3,-2,-2,-2,-1,-1,-1, 0, 0, 0, 1, 1, 0, 1, 2, 2, 2, 3, 3, 4, 4, 5, 6, 5, 6, 8}, 46 | {-3,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0,-1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 2, 1, 2, 2, 2, 2, 3}, 47 | { 3, 3, 2, 2, 2, 2, 1, 2, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,-1, 0, 0,-1,-1,-1,-1,-1,-2,-2,-2}, 48 | { 9, 8, 6, 5, 6, 5, 4, 4, 3, 3, 2, 2, 2, 1, 0, 1, 1, 0, 0, 0,-1,-1,-1,-2,-2,-2,-3,-3,-4,-4,-5,-5,-6,-7} 49 | }; 50 | 51 | const SKP_int16 SKP_Silk_Lag_range_stage3[ SKP_Silk_PITCH_EST_MAX_COMPLEX + 1 ] [ PITCH_EST_NB_SUBFR ][ 2 ] = 52 | { 53 | /* Lags to search for low number of stage3 cbks */ 54 | { 55 | {-2,6}, 56 | {-1,5}, 57 | {-1,5}, 58 | {-2,7} 59 | }, 60 | /* Lags to search for middle number of stage3 cbks */ 61 | { 62 | {-4,8}, 63 | {-1,6}, 64 | {-1,6}, 65 | {-4,9} 66 | }, 67 | /* Lags to search for max number of stage3 cbks */ 68 | { 69 | {-9,12}, 70 | {-3,7}, 71 | {-2,7}, 72 | {-7,13} 73 | } 74 | }; 75 | 76 | const SKP_int16 SKP_Silk_cbk_sizes_stage3[SKP_Silk_PITCH_EST_MAX_COMPLEX + 1] = 77 | { 78 | PITCH_EST_NB_CBKS_STAGE3_MIN, 79 | PITCH_EST_NB_CBKS_STAGE3_MID, 80 | PITCH_EST_NB_CBKS_STAGE3_MAX 81 | }; 82 | 83 | const SKP_int16 SKP_Silk_cbk_offsets_stage3[SKP_Silk_PITCH_EST_MAX_COMPLEX + 1] = 84 | { 85 | ((PITCH_EST_NB_CBKS_STAGE3_MAX - PITCH_EST_NB_CBKS_STAGE3_MIN) >> 1), 86 | ((PITCH_EST_NB_CBKS_STAGE3_MAX - PITCH_EST_NB_CBKS_STAGE3_MID) >> 1), 87 | 0 88 | }; 89 | 90 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_regularize_correlations_FIX.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_main_FIX.h" 29 | 30 | /* Add noise to matrix diagonal */ 31 | void SKP_Silk_regularize_correlations_FIX( 32 | SKP_int32 *XX, /* I/O Correlation matrices */ 33 | SKP_int32 *xx, /* I/O Correlation values */ 34 | SKP_int32 noise, /* I Noise to add */ 35 | SKP_int D /* I Dimension of XX */ 36 | ) 37 | { 38 | SKP_int i; 39 | for( i = 0; i < D; i++ ) { 40 | matrix_ptr( &XX[ 0 ], i, i, D ) = SKP_ADD32( matrix_ptr( &XX[ 0 ], i, i, D ), noise ); 41 | } 42 | xx[ 0 ] += noise; 43 | } 44 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_resampler_down2_arm.S: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #if defined(__arm__) 29 | 30 | #include "SKP_Silk_AsmPreproc.h" 31 | 32 | #if EMBEDDED_ARM>=5 33 | #define SKP_Silk_resampler_down2_0 0x2690 34 | #define SKP_Silk_resampler_down2_1 0x9B81 35 | 36 | VARDEF xy0, r4 37 | VARDEF xy1, r5 38 | VARDEF down2_coefs, _r7 39 | VARDEF S_0, r6 40 | VARDEF S_1, r8 41 | VARDEF in0, sb 42 | VARDEF in1, sl 43 | VARDEF out32, r0 44 | 45 | .set sp_S, 0 46 | .globl SYM(SKP_Silk_resampler_down2) 47 | SYM(SKP_Silk_resampler_down2): 48 | stmdb sp!, {r4-r10, fp, ip, lr} 49 | add fp, sp, #36 50 | sub sp, sp, #4 51 | ldrsh in0, [r2], #2 // Avoid un-aligned access 52 | ldrsh in1, [r2], #2 53 | str r0, [sp, #sp_S] 54 | ldmia r0, {S_0, S_1} 55 | mov down2_coefs, #0x26000000 56 | add down2_coefs, down2_coefs, #0x900000 57 | add down2_coefs, down2_coefs, #0x9B00 58 | add down2_coefs, down2_coefs, #0x81 59 | mov r3, r3, asr #1 60 | mov ip, #1024 61 | L(0) 62 | add out32, S_0, S_1 63 | rsb xy0, S_0, in0, lsl #10 64 | rsb xy1, S_1, in1, lsl #10 65 | smlawb xy0, xy0, down2_coefs, xy0 66 | smulwt xy1, xy1, down2_coefs 67 | add out32, out32, xy0 68 | add S_0, xy0, in0, lsl #10 69 | add out32, out32, xy1 70 | add S_1, xy1, in1, lsl #10 71 | #if EMBEDDED_ARM>=6 72 | qadd out32, out32, ip 73 | subs r3, r3, #1 74 | ssat out32, #16, out32, asr #11 75 | #ifdef _WINRT 76 | ble LR(1, f) 77 | ldrsh in0, [r2], #2 78 | ldrsh in1, [r2], #2 79 | L(1) 80 | #else 81 | ldrgtsh in0, [r2], #2 82 | ldrgtsh in1, [r2], #2 83 | #endif 84 | #else 85 | qadd out32, out32, ip 86 | cmp out32, #0x4000000 87 | movge out32, #0x4000000 88 | subge out32, out32, #1 89 | cmn out32, #0x4000000 90 | movlt out32, #0x4000000 91 | subs r3, r3, #1 92 | mov out32, out32, asr #11 93 | ldrgtsh in0, [r2], #2 94 | ldrgtsh in1, [r2], #2 95 | #endif 96 | 97 | strh out32, [r1], #2 98 | bgt LR(0, b) 99 | 100 | ldr r0, [sp, #sp_S] 101 | stmia r0, {S_0, S_1} 102 | 103 | add sp, sp, #4 104 | ldmia sp!, {r4-r10, fp, ip, pc} 105 | END 106 | #endif 107 | #endif 108 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_resampler_private_AR2.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | /* * 29 | * SKP_Silk_resampler_private_AR2. c * 30 | * * 31 | * Second order AR filter with single delay elements * 32 | * * 33 | * Copyright 2010 (c), Skype Limited * 34 | * */ 35 | 36 | #include "SKP_Silk_SigProc_FIX.h" 37 | #include "SKP_Silk_resampler_private.h" 38 | 39 | #if (EMBEDDED_ARM<5) 40 | /* Second order AR filter with single delay elements */ 41 | void SKP_Silk_resampler_private_AR2( 42 | SKP_int32 S[], /* I/O: State vector [ 2 ] */ 43 | SKP_int32 out_Q8[], /* O: Output signal */ 44 | const SKP_int16 in[], /* I: Input signal */ 45 | const SKP_int16 A_Q14[], /* I: AR coefficients, Q14 */ 46 | SKP_int32 len /* I: Signal length */ 47 | ) 48 | { 49 | SKP_int32 k; 50 | SKP_int32 out32; 51 | 52 | for( k = 0; k < len; k++ ) { 53 | out32 = SKP_ADD_LSHIFT32( S[ 0 ], (SKP_int32)in[ k ], 8 ); 54 | out_Q8[ k ] = out32; 55 | out32 = SKP_LSHIFT( out32, 2 ); 56 | S[ 0 ] = SKP_SMLAWB( S[ 1 ], out32, A_Q14[ 0 ] ); 57 | S[ 1 ] = SKP_SMULWB( out32, A_Q14[ 1 ] ); 58 | } 59 | } 60 | #endif 61 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_resampler_private_AR2_arm.S: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #if defined(__arm__) 29 | 30 | #include "SKP_Silk_AsmPreproc.h" 31 | 32 | #if EMBEDDED_ARM>=5 33 | 34 | VARDEF len, r4 35 | VARDEF S_0, r5 36 | VARDEF S_1, r6 37 | VARDEF in0, _r7 38 | VARDEF out32, r8 39 | VARDEF A_Q140, sb 40 | VARDEF A_Q141, sl 41 | 42 | .set sp_S, 0 43 | .globl SYM(SKP_Silk_resampler_private_AR2) 44 | SYM(SKP_Silk_resampler_private_AR2): 45 | stmdb sp!, {r4-r10, fp, ip, lr} 46 | add fp, sp, #36 47 | sub sp, sp, #4 48 | .set sp_len, 44 49 | 50 | str r0, [sp, #sp_S] 51 | ldr S_0, [r0], #4 52 | ldr S_1, [r0], #-4 53 | ldr len, [sp, #sp_len] 54 | ldrsh A_Q140, [r3], #2 55 | ldrsh A_Q141, [r3] 56 | cmp len, #0 57 | beq LR(1, f) 58 | 59 | L(0) 60 | ldrsh in0, [r2], #2 61 | add out32, S_0, in0, lsl #8 62 | str out32, [r1], #4 63 | subs len, len, #1 64 | mov out32, out32, lsl #2 65 | smlawb S_0, out32, A_Q140, S_1 66 | smulwb S_1, out32, A_Q141 67 | bgt LR(0, b) 68 | 69 | str S_0, [r0], #4 70 | str S_1, [r0] 71 | L(1) 72 | add sp, sp, #4 73 | ldmia sp!, {r4-r10, fp, ip, pc} 74 | END 75 | #endif 76 | #endif 77 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_resampler_private_IIR_FIR_arm.S: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #if defined(__arm__) 29 | 30 | #include "SKP_Silk_AsmPreproc.h" 31 | 32 | #if EMBEDDED_ARM>=5 33 | 34 | VARDEF ind, r4 35 | VARDEF tab1, r5 36 | VARDEF tab2, r6 37 | VARDEF tab3, _r7 38 | VARDEF val1, r8 39 | VARDEF val2, sb 40 | VARDEF val3, r2 41 | VARDEF val4, r3 42 | VARDEF tmp1, sl 43 | VARDEF tmp2, r2 44 | VARDEF tmp3, r3 45 | VARDEF tmp4, ip 46 | VARDEF out, sl 47 | 48 | .set sp_max_i, 0 49 | .set sp_inc, 4 50 | 51 | EXTERN SYM(SKP_Silk_resampler_frac_FIR_144_alt) 52 | .globl SYM(SKP_Silk_resampler_private_IIR_FIR_INTERPOL) 53 | SYM(SKP_Silk_resampler_private_IIR_FIR_INTERPOL): 54 | stmdb sp!, {r4-r10, fp, ip, lr} 55 | add fp, sp, #36 56 | sub sp, sp, #8 57 | str r2, [sp, #sp_max_i] 58 | str r3, [sp, #sp_inc] 59 | cmp r2, #0 60 | mov tmp3, #0xFF00 61 | mov ind, #0 62 | ble LR(1, f) 63 | add tmp3, tmp3, #0xFF 64 | L(0) 65 | ldr tmp1, TABLE(L0, =SKP_Silk_resampler_frac_FIR_144_alt) 66 | and tmp3, ind, tmp3 67 | mov tmp2, #144 68 | mov tmp4, ind, asr #16 69 | smulwb tmp2, tmp3, tmp2 70 | add tmp1, tmp1, tmp2, lsl #3 71 | add tmp1, tmp1, tmp2, lsl #2 72 | add tmp4, r1, tmp4, lsl #1 73 | 74 | ldmia tmp1, {tab1, tab2, tab3} 75 | ldrsh val1, [tmp4], #2 76 | ldrsh val2, [tmp4], #2 77 | ldrsh val3, [tmp4], #2 78 | ldrsh val4, [tmp4], #2 79 | smulbb out, val1, tab1 80 | smlabt out, val2, tab1, out 81 | ldrsh val1, [tmp4], #2 82 | ldrsh val2, [tmp4] 83 | smlabb out, val3, tab2, out 84 | smlabt out, val4, tab2, out 85 | ldr r2, [sp, #sp_max_i] 86 | ldr r3, [sp, #sp_inc] 87 | smlabb out, val1, tab3, out 88 | smlabt out, val2, tab3, out 89 | add ind, ind, r3 90 | adds out, out, #1<<14 91 | mov tmp3, #0xFF00 92 | #ifdef _WINRT 93 | bvc LR(2, f) 94 | mvn out, #0x80000000 95 | b LR(3, f) 96 | L(2) 97 | qadd out, out, out 98 | L(3) 99 | #else 100 | mvnvs out, #0x80000000 101 | qaddvc out, out, out 102 | #endif 103 | add tmp3, tmp3, #0xFF 104 | mov out, out, asr #16 105 | cmp ind, r2 106 | strh out, [r0], #2 107 | blt LR(0, b) 108 | L(1) 109 | add sp, sp, #8 110 | ldmia sp!, {r4-r10, fp, ip, pc} 111 | 112 | L(L0) 113 | DCD SYM(SKP_Silk_resampler_frac_FIR_144_alt) 114 | END 115 | #endif 116 | #endif 117 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_resampler_private_copy.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | /* * 29 | * File Name: SKP_Silk_resampler_private_copy.c * 30 | * * 31 | * Description: Copy. * 32 | * * 33 | * Copyright 2010 (c), Skype Limited * 34 | * All rights reserved. * 35 | * */ 36 | 37 | #include "SKP_Silk_SigProc_FIX.h" 38 | #include "SKP_Silk_resampler_private.h" 39 | 40 | /* Copy */ 41 | void SKP_Silk_resampler_private_copy( 42 | void *SS, /* I/O: Resampler state (unused) */ 43 | SKP_int16 out[], /* O: Output signal */ 44 | const SKP_int16 in[], /* I: Input signal */ 45 | SKP_int32 inLen /* I: Number of input samples */ 46 | ) 47 | { 48 | SKP_memcpy( out, in, inLen * sizeof( SKP_int16 ) ); 49 | } 50 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_resampler_structs.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | /* * 29 | * File Name: SKP_Silk_resampler_structs.h * 30 | * * 31 | * Description: Structs for IIR/FIR resamplers * 32 | * * 33 | * Copyright 2010 (c), Skype Limited * 34 | * All rights reserved. * 35 | * * 36 | * */ 37 | 38 | #ifndef SKP_Silk_RESAMPLER_STRUCTS_H 39 | #define SKP_Silk_RESAMPLER_STRUCTS_H 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | /* Flag to enable support for input/output sampling rates above 48 kHz. Turn off for embedded devices */ 46 | #define RESAMPLER_SUPPORT_ABOVE_48KHZ 1 47 | 48 | #define SKP_Silk_RESAMPLER_MAX_FIR_ORDER 16 49 | #define SKP_Silk_RESAMPLER_MAX_IIR_ORDER 6 50 | 51 | 52 | typedef struct _SKP_Silk_resampler_state_struct{ 53 | SKP_int32 sIIR[ SKP_Silk_RESAMPLER_MAX_IIR_ORDER ]; /* this must be the first element of this struct */ 54 | SKP_int32 sFIR[ SKP_Silk_RESAMPLER_MAX_FIR_ORDER ]; 55 | SKP_int32 sDown2[ 2 ]; 56 | void (*resampler_function)( void *, SKP_int16 *, const SKP_int16 *, SKP_int32 ); 57 | void (*up2_function)( SKP_int32 *, SKP_int16 *, const SKP_int16 *, SKP_int32 ); 58 | SKP_int32 batchSize; 59 | SKP_int32 invRatio_Q16; 60 | SKP_int32 FIR_Fracs; 61 | SKP_int32 input2x; 62 | const SKP_int16 *Coefs; 63 | #if RESAMPLER_SUPPORT_ABOVE_48KHZ 64 | SKP_int32 sDownPre[ 2 ]; 65 | SKP_int32 sUpPost[ 2 ]; 66 | void (*down_pre_function)( SKP_int32 *, SKP_int16 *, const SKP_int16 *, SKP_int32 ); 67 | void (*up_post_function)( SKP_int32 *, SKP_int16 *, const SKP_int16 *, SKP_int32 ); 68 | SKP_int32 batchSizePrePost; 69 | SKP_int32 ratio_Q16; 70 | SKP_int32 nPreDownsamplers; 71 | SKP_int32 nPostUpsamplers; 72 | #endif 73 | SKP_int32 magic_number; 74 | } SKP_Silk_resampler_state_struct; 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | #endif /* SKP_Silk_RESAMPLER_STRUCTS_H */ 80 | 81 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_resampler_up2_arm.S: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #if defined(__arm__) 29 | 30 | #include "SKP_Silk_AsmPreproc.h" 31 | 32 | #if EMBEDDED_ARM>=5 33 | #define SKP_Silk_resampler_up2_lq_0 0x1FA6 34 | #define SKP_Silk_resampler_up2_lq_1 0x8FAF 35 | 36 | VARDEF xy0, r4 37 | VARDEF xy1, r5 38 | VARDEF up2_coefs, _r7 39 | VARDEF S_0, r6 40 | VARDEF S_1, r8 41 | VARDEF in, sb 42 | VARDEF out0, sl 43 | VARDEF out1, r0 44 | 45 | .set sp_S, 0 46 | .globl SYM(SKP_Silk_resampler_up2) 47 | SYM(SKP_Silk_resampler_up2): 48 | stmdb sp!, {r4-r10, fp, ip, lr} 49 | add fp, sp, #36 50 | sub sp, sp, #4 51 | mov up2_coefs, #0x1F000000 52 | ldrsh in, [r2], #2 53 | add up2_coefs, up2_coefs, #0xA60000 54 | str r0, [sp, #sp_S] 55 | add up2_coefs, up2_coefs, #0x8F00 56 | ldmia r0, {S_0, S_1} 57 | add up2_coefs, up2_coefs, #0xAF 58 | mov ip, #512 59 | cmp r3, #0 60 | beq LR(1, f) 61 | L(0) 62 | mov in, in, lsl #10 63 | sub xy0, in, S_0 64 | sub xy1, in, S_1 65 | smulwt xy0, xy0, up2_coefs 66 | smlawb xy1, xy1, up2_coefs, xy1 67 | add out0, S_0, xy0 68 | add out1, S_1, xy1 69 | add S_0, in, xy0 70 | add S_1, in, xy1 71 | qadd out0, out0, ip 72 | qadd out1, out1, ip 73 | #if EMBEDDED_ARM<6 74 | cmp out0, #0x2000000 75 | movge out0, #0x2000000 76 | subge out0, out0, #1 77 | cmn out0, #0x2000000 78 | movlt out0, #0x2000000 79 | cmp out1, #0x2000000 80 | movge out1, #0x2000000 81 | subge out1 ,out1, #1 82 | cmn out1, #0x2000000 83 | movlt out1, #0x2000000 84 | mov out0, out0, asr #10 85 | mov out1, out1, asr #10 86 | #else 87 | ssat out0, #16, out0, asr #10 88 | ssat out1, #16, out1, asr #10 89 | #endif 90 | subs r3, r3, #1 91 | #ifdef _WINRT 92 | ble LR(2, f) 93 | ldrsh in, [r2], #2 94 | strh out0, [r1], #2 95 | strh out1, [r1], #2 96 | b LR(0, b) 97 | L(2) 98 | strh out0, [r1], #2 99 | strh out1, [r1], #2 100 | #else 101 | ldrgtsh in, [r2], #2 102 | strh out0, [r1], #2 103 | strh out1, [r1], #2 104 | bgt LR(0, b) 105 | #endif 106 | 107 | ldr r0, [sp, #sp_S] 108 | stmia r0, {S_0, S_1} 109 | L(1) 110 | add sp, sp, #4 111 | ldmia sp!, {r4-r10, fp, ip, pc} 112 | END 113 | #endif 114 | #endif 115 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_scale_copy_vector16.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_SigProc_FIX.h" 29 | 30 | /* Copy and multiply a vector by a constant */ 31 | void SKP_Silk_scale_copy_vector16( 32 | SKP_int16 *data_out, 33 | const SKP_int16 *data_in, 34 | SKP_int32 gain_Q16, /* (I): gain in Q16 */ 35 | const SKP_int dataSize /* (I): length */ 36 | ) 37 | { 38 | SKP_int i; 39 | SKP_int32 tmp32; 40 | 41 | for( i = 0; i < dataSize; i++ ) { 42 | tmp32 = SKP_SMULWB( gain_Q16, data_in[ i ] ); 43 | data_out[ i ] = (SKP_int16)SKP_CHECK_FIT16( tmp32 ); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_scale_vector.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_SigProc_FIX.h" 29 | 30 | /* Multiply a vector by a constant */ 31 | void SKP_Silk_scale_vector32_Q26_lshift_18( 32 | SKP_int32 *data1, /* (I/O): Q0/Q18 */ 33 | SKP_int32 gain_Q26, /* (I): Q26 */ 34 | SKP_int dataSize /* (I): length */ 35 | ) 36 | { 37 | SKP_int i; 38 | 39 | for( i = 0; i < dataSize; i++ ) { 40 | data1[ i ] = (SKP_int32)SKP_CHECK_FIT32( SKP_RSHIFT64( SKP_SMULL( data1[ i ], gain_Q26 ), 8 ) );// OUTPUT: Q18 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_sigm_Q15.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | /* * 29 | * SKP_sigm_Q15.c * 30 | * * 31 | * Approximate sigmoid function * 32 | * * 33 | * Copyright 2006 (c), Skype Limited * 34 | * Date: 060221 * 35 | * */ 36 | #include "SKP_Silk_SigProc_FIX.h" 37 | #if EMBEDDED_ARM<4 38 | /********************************/ 39 | /* approximate sigmoid function */ 40 | /********************************/ 41 | /* fprintf(1, '%d, ', round(1024 * ([1 ./ (1 + exp(-(1:5))), 1] - 1 ./ (1 + exp(-(0:5)))))); */ 42 | static const SKP_int32 sigm_LUT_slope_Q10[ 6 ] = { 43 | 237, 153, 73, 30, 12, 7 44 | }; 45 | /* fprintf(1, '%d, ', round(32767 * 1 ./ (1 + exp(-(0:5))))); */ 46 | static const SKP_int32 sigm_LUT_pos_Q15[ 6 ] = { 47 | 16384, 23955, 28861, 31213, 32178, 32548 48 | }; 49 | /* fprintf(1, '%d, ', round(32767 * 1 ./ (1 + exp((0:5))))); */ 50 | static const SKP_int32 sigm_LUT_neg_Q15[ 6 ] = { 51 | 16384, 8812, 3906, 1554, 589, 219 52 | }; 53 | 54 | SKP_int SKP_Silk_sigm_Q15( SKP_int in_Q5 ) 55 | { 56 | SKP_int ind; 57 | 58 | if( in_Q5 < 0 ) { 59 | /* Negative input */ 60 | in_Q5 = -in_Q5; 61 | if( in_Q5 >= 6 * 32 ) { 62 | return 0; /* Clip */ 63 | } else { 64 | /* Linear interpolation of look up table */ 65 | ind = SKP_RSHIFT( in_Q5, 5 ); 66 | return( sigm_LUT_neg_Q15[ ind ] - SKP_SMULBB( sigm_LUT_slope_Q10[ ind ], in_Q5 & 0x1F ) ); 67 | } 68 | } else { 69 | /* Positive input */ 70 | if( in_Q5 >= 6 * 32 ) { 71 | return 32767; /* clip */ 72 | } else { 73 | /* Linear interpolation of look up table */ 74 | ind = SKP_RSHIFT( in_Q5, 5 ); 75 | return( sigm_LUT_pos_Q15[ ind ] + SKP_SMULBB( sigm_LUT_slope_Q10[ ind ], in_Q5 & 0x1F ) ); 76 | } 77 | } 78 | } 79 | #endif 80 | 81 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_sigm_Q15_arm.S: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #if defined(__arm__) 29 | 30 | #include "SKP_Silk_AsmPreproc.h" 31 | #if EMBEDDED_ARM>=4 32 | 33 | VARDEF ptr_slope, r6 34 | VARDEF ptr_LUT, _r7 35 | VARDEF in_Q5, r1 36 | VARDEF ind, r2 37 | VARDEF val_slope, r5 38 | VARDEF val_PUT, r4 39 | VARDEF in_Q5_tmp, r3 40 | 41 | .globl SYM(SKP_Silk_sigm_Q15) 42 | SYM(SKP_Silk_sigm_Q15): 43 | stmdb sp!, {r4-r7, fp, ip, lr} 44 | add fp, sp, #24 45 | cmp r0, #0 46 | ldr ptr_slope, TABLE(L0, =SKP_Silk_sigm_tab) 47 | 48 | mov in_Q5, r0 49 | rsblt in_Q5, r0, #0 50 | mov r0, #32768 51 | addlt ptr_slope, ptr_slope, #24 52 | movlt r0, #1 53 | add ptr_LUT, ptr_slope, #12 /*sigm_LUT_pos_Q15*/ 54 | cmp in_Q5, #192 /*6*32*/ 55 | sub r0, r0, #1 56 | 57 | bge LR(1, f) 58 | mov ind, in_Q5, asr #5 /*ind*/ 59 | mov ind, ind, lsl #1 60 | and in_Q5_tmp, in_Q5, #0x1F 61 | ldrsh val_slope, [ptr_slope, ind] /*sigm_LUT_slope_Q10*/ 62 | ldrsh val_PUT, [ptr_LUT, ind] /*sigm_LUT_pos/neg_Q15*/ 63 | mla r0, val_slope, in_Q5_tmp, val_PUT 64 | L(1) 65 | ldmia sp!, {r4-r7, fp, ip, pc} 66 | 67 | L(L0) 68 | DCD SYM(SKP_Silk_sigm_tab) 69 | 70 | SKP_TABLE SKP_Silk_sigm_tab, 2 71 | DCW 237, 153, 73, 30, 12, 7, \ 72 | 16384, 23955, 28861, 31213, 32178, 32548, \ 73 | -237, -153, -73, -30, -12, -7, \ 74 | 16384, 8812, 3906, 1554, 589, 219 75 | END 76 | #endif 77 | #endif 78 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_sum_sqr_shift_arm.S: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #if defined(__arm__) 29 | 30 | #include "SKP_Silk_AsmPreproc.h" 31 | #if EMBEDDED_ARM>=5 32 | 33 | VARDEF x0, r4 34 | VARDEF nrg_tmp, r5 35 | VARDEF shift, r6 36 | VARDEF nrg, _r7 37 | VARDEF idx, r8 38 | 39 | .globl SYM(SKP_Silk_sum_sqr_shift) 40 | SYM(SKP_Silk_sum_sqr_shift): 41 | stmdb sp!, {r4-r8, fp, ip, lr} 42 | add fp, sp, #28 43 | mov idx, r3 44 | ands nrg_tmp, r2, #2 45 | mov nrg, #0 46 | #ifdef _WINRT 47 | beq LR(6, f) 48 | ldrh x0, [r2], #2 49 | smulbb nrg, x0, x0 50 | sub idx, idx, #1 51 | L(6) 52 | #else 53 | ldrneh x0, [r2], #2 54 | smulbbne nrg, x0, x0 55 | subne idx, idx, #1 56 | #endif 57 | 58 | ldr r4, [r2], #4 59 | mov shift, #0 60 | sub idx, idx, #1 61 | L(0) 62 | subs idx, idx, #2 63 | SKP_SMLAD nrg, x0, x0, nrg 64 | #ifdef _WINRT 65 | ldrgt x0, [r2] 66 | addgt r2, r2, #4 67 | #else 68 | ldrgt x0, [r2], #4 69 | #endif 70 | cmp nrg, #0 71 | blt LR(1, f) 72 | cmp idx, #0 73 | bgt LR(0, b) 74 | beq LR(4, f) 75 | b LR(5, f) 76 | L(1) 77 | mov nrg, nrg, lsr #2 78 | mov shift, #2 79 | cmp idx, #0 80 | beq LR(4, f) 81 | blt LR(5, f) 82 | L(3) 83 | subs idx, idx, #2 84 | SKP_SMUAD nrg_tmp, x0, x0 85 | #ifdef _WINRT 86 | ldrgt x0, [r2] 87 | addgt r2, r2, #4 88 | mov nrg_tmp, nrg_tmp, lsr shift 89 | adds nrg, nrg, nrg_tmp 90 | #else 91 | ldrgt x0, [r2], #4 92 | add nrg, nrg, nrg_tmp, lsr shift 93 | cmp nrg, #0 94 | #endif 95 | movlt nrg, nrg, lsr #2 96 | addlt shift, shift, #2 97 | cmp idx, #0 98 | bgt LR(3, b) 99 | blt LR(5, f) 100 | L(4) 101 | ldrh x0, [r2] 102 | smulbb nrg_tmp, x0, x0 103 | #ifdef _WINRT 104 | mov nrg_tmp, nrg_tmp, lsr shift 105 | add nrg, nrg, nrg_tmp 106 | #else 107 | add nrg, nrg, nrg_tmp, lsr shift 108 | #endif 109 | L(5) 110 | ands nrg_tmp, nrg, #0xC0000000 111 | movne nrg, nrg, lsr #2 112 | addne shift, shift, #2 113 | str shift, [r1] 114 | str nrg, [r0] 115 | 116 | ldmia sp!, {r4-r8, fp, ip, pc} 117 | END 118 | #endif 119 | #endif 120 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_tables_NLSF_CB0_10.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifndef SKP_SILK_TABLES_NLSF_CB0_10_H 29 | #define SKP_SILK_TABLES_NLSF_CB0_10_H 30 | 31 | #include "SKP_Silk_define.h" 32 | 33 | #ifdef __cplusplus 34 | extern "C" 35 | { 36 | #endif 37 | 38 | #define NLSF_MSVQ_CB0_10_STAGES 6 39 | #define NLSF_MSVQ_CB0_10_VECTORS 120 40 | 41 | /* NLSF codebook entropy coding tables */ 42 | extern const SKP_uint16 SKP_Silk_NLSF_MSVQ_CB0_10_CDF[ NLSF_MSVQ_CB0_10_VECTORS + NLSF_MSVQ_CB0_10_STAGES ]; 43 | extern const SKP_uint16 * const SKP_Silk_NLSF_MSVQ_CB0_10_CDF_start_ptr[ NLSF_MSVQ_CB0_10_STAGES ]; 44 | extern const SKP_int SKP_Silk_NLSF_MSVQ_CB0_10_CDF_middle_idx[ NLSF_MSVQ_CB0_10_STAGES ]; 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_tables_NLSF_CB0_16.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifndef SKP_SILK_TABLES_NLSF_CB0_16_H 29 | #define SKP_SILK_TABLES_NLSF_CB0_16_H 30 | 31 | #include "SKP_Silk_define.h" 32 | 33 | #ifdef __cplusplus 34 | extern "C" 35 | { 36 | #endif 37 | 38 | #define NLSF_MSVQ_CB0_16_STAGES 10 39 | #define NLSF_MSVQ_CB0_16_VECTORS 216 40 | 41 | /* NLSF codebook entropy coding tables */ 42 | extern const SKP_uint16 SKP_Silk_NLSF_MSVQ_CB0_16_CDF[ NLSF_MSVQ_CB0_16_VECTORS + NLSF_MSVQ_CB0_16_STAGES ]; 43 | extern const SKP_uint16 * const SKP_Silk_NLSF_MSVQ_CB0_16_CDF_start_ptr[ NLSF_MSVQ_CB0_16_STAGES ]; 44 | extern const SKP_int SKP_Silk_NLSF_MSVQ_CB0_16_CDF_middle_idx[ NLSF_MSVQ_CB0_16_STAGES ]; 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_tables_NLSF_CB1_10.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifndef SKP_SILK_TABLES_NLSF_CB1_10_H 29 | #define SKP_SILK_TABLES_NLSF_CB1_10_H 30 | 31 | #include "SKP_Silk_define.h" 32 | 33 | #ifdef __cplusplus 34 | extern "C" 35 | { 36 | #endif 37 | 38 | #define NLSF_MSVQ_CB1_10_STAGES 6 39 | #define NLSF_MSVQ_CB1_10_VECTORS 72 40 | 41 | /* NLSF codebook entropy coding tables */ 42 | extern const SKP_uint16 SKP_Silk_NLSF_MSVQ_CB1_10_CDF[ NLSF_MSVQ_CB1_10_VECTORS + NLSF_MSVQ_CB1_10_STAGES ]; 43 | extern const SKP_uint16 * const SKP_Silk_NLSF_MSVQ_CB1_10_CDF_start_ptr[ NLSF_MSVQ_CB1_10_STAGES ]; 44 | extern const SKP_int SKP_Silk_NLSF_MSVQ_CB1_10_CDF_middle_idx[ NLSF_MSVQ_CB1_10_STAGES ]; 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_tables_NLSF_CB1_16.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #ifndef SKP_SILK_TABLES_NLSF_CB1_16_H 29 | #define SKP_SILK_TABLES_NLSF_CB1_16_H 30 | 31 | #include "SKP_Silk_define.h" 32 | 33 | #ifdef __cplusplus 34 | extern "C" 35 | { 36 | #endif 37 | 38 | #define NLSF_MSVQ_CB1_16_STAGES 10 39 | #define NLSF_MSVQ_CB1_16_VECTORS 104 40 | 41 | /* NLSF codebook entropy coding tables */ 42 | extern const SKP_uint16 SKP_Silk_NLSF_MSVQ_CB1_16_CDF[ NLSF_MSVQ_CB1_16_VECTORS + NLSF_MSVQ_CB1_16_STAGES ]; 43 | extern const SKP_uint16 * const SKP_Silk_NLSF_MSVQ_CB1_16_CDF_start_ptr[ NLSF_MSVQ_CB1_16_STAGES ]; 44 | extern const SKP_int SKP_Silk_NLSF_MSVQ_CB1_16_CDF_middle_idx[ NLSF_MSVQ_CB1_16_STAGES ]; 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_tables_gain.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_tables.h" 29 | 30 | #ifdef __cplusplus 31 | extern "C" 32 | { 33 | #endif 34 | 35 | const SKP_uint16 SKP_Silk_gain_CDF[ 2 ][ 65 ] = 36 | { 37 | { 38 | 0, 18, 45, 94, 181, 320, 519, 777, 39 | 1093, 1468, 1909, 2417, 2997, 3657, 4404, 5245, 40 | 6185, 7228, 8384, 9664, 11069, 12596, 14244, 16022, 41 | 17937, 19979, 22121, 24345, 26646, 29021, 31454, 33927, 42 | 36438, 38982, 41538, 44068, 46532, 48904, 51160, 53265, 43 | 55184, 56904, 58422, 59739, 60858, 61793, 62568, 63210, 44 | 63738, 64165, 64504, 64769, 64976, 65133, 65249, 65330, 45 | 65386, 65424, 65451, 65471, 65487, 65501, 65513, 65524, 46 | 65535 47 | }, 48 | { 49 | 0, 214, 581, 1261, 2376, 3920, 5742, 7632, 50 | 9449, 11157, 12780, 14352, 15897, 17427, 18949, 20462, 51 | 21957, 23430, 24889, 26342, 27780, 29191, 30575, 31952, 52 | 33345, 34763, 36200, 37642, 39083, 40519, 41930, 43291, 53 | 44602, 45885, 47154, 48402, 49619, 50805, 51959, 53069, 54 | 54127, 55140, 56128, 57101, 58056, 58979, 59859, 60692, 55 | 61468, 62177, 62812, 63368, 63845, 64242, 64563, 64818, 56 | 65023, 65184, 65306, 65391, 65447, 65482, 65505, 65521, 57 | 65535 58 | } 59 | }; 60 | 61 | const SKP_int SKP_Silk_gain_CDF_offset = 32; 62 | 63 | 64 | const SKP_uint16 SKP_Silk_delta_gain_CDF[ 46 ] = { 65 | 0, 2358, 3856, 7023, 15376, 53058, 59135, 61555, 66 | 62784, 63498, 63949, 64265, 64478, 64647, 64783, 64894, 67 | 64986, 65052, 65113, 65169, 65213, 65252, 65284, 65314, 68 | 65338, 65359, 65377, 65392, 65403, 65415, 65424, 65432, 69 | 65440, 65448, 65455, 65462, 65470, 65477, 65484, 65491, 70 | 65499, 65506, 65513, 65521, 65528, 65535 71 | }; 72 | 73 | const SKP_int SKP_Silk_delta_gain_CDF_offset = 5; 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_tables_sign.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_tables.h" 29 | 30 | const SKP_uint16 SKP_Silk_sign_CDF[ 36 ] = 31 | { 32 | 37840, 36944, 36251, 35304, 33 | 34715, 35503, 34529, 34296, 34 | 34016, 47659, 44945, 42503, 35 | 40235, 38569, 40254, 37851, 36 | 37243, 36595, 43410, 44121, 37 | 43127, 40978, 38845, 40433, 38 | 38252, 37795, 36637, 59159, 39 | 55630, 51806, 48073, 45036, 40 | 48416, 43857, 42678, 41146, 41 | }; 42 | 43 | -------------------------------------------------------------------------------- /libs/oneui-audio/src/src/SKP_Silk_tables_type_offset.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Copyright (c) 2006-2012, Skype Limited. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, (subject to the limitations in the disclaimer below) 5 | are permitted provided that the following conditions are met: 6 | - Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | - Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | - Neither the name of Skype Limited, nor the names of specific 12 | contributors, may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 15 | BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 16 | CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ***********************************************************************/ 27 | 28 | #include "SKP_Silk_tables.h" 29 | 30 | const SKP_uint16 SKP_Silk_type_offset_CDF[ 5 ] = { 31 | 0, 37522, 41030, 44212, 65535 32 | }; 33 | 34 | const SKP_int SKP_Silk_type_offset_CDF_offset = 2; 35 | 36 | 37 | const SKP_uint16 SKP_Silk_type_offset_joint_CDF[ 4 ][ 5 ] = 38 | { 39 | { 40 | 0, 57686, 61230, 62358, 65535 41 | }, 42 | { 43 | 0, 18346, 40067, 43659, 65535 44 | }, 45 | { 46 | 0, 22694, 24279, 35507, 65535 47 | }, 48 | { 49 | 0, 6067, 7215, 13010, 65535 50 | } 51 | }; 52 | 53 | -------------------------------------------------------------------------------- /libs/oneui-audio/yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | "@types/emscripten@^1.39.4": 6 | version "1.39.4" 7 | resolved "https://registry.npm.taobao.org/@types/emscripten/download/@types/emscripten-1.39.4.tgz#d61990c0cee72c4e475de737a140b51fe925a2c8" 8 | integrity sha1-1hmQwM7nLE5HXec3oUC1H+klosg= 9 | 10 | emscripten@^0.0.2-beta: 11 | version "0.0.2-beta" 12 | resolved "https://registry.npm.taobao.org/emscripten/download/emscripten-0.0.2-beta.tgz#f3dab87f92ae36d5282511f4bbd6a066944fcda6" 13 | integrity sha1-89q4f5KuNtUoJRH0u9agZpRPzaY= 14 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "oneui", 3 | "version": "0.0.4", 4 | "scripts": { 5 | "build": "rollup -c", 6 | "dev": "rollup -c -w", 7 | "start": "sirv public" 8 | }, 9 | "description": "A frontend gui for onebot backend.", 10 | "main": "src/index.ts", 11 | "repository": "git@github.com:Steve-xmh/oneui.git", 12 | "author": "Steve-xmh ", 13 | "license": "CC0-1.0", 14 | "devDependencies": { 15 | "@mdi/font": "^5.9.55", 16 | "@mdi/js": "^5.9.55", 17 | "@rollup/plugin-commonjs": "^17.0.0", 18 | "@rollup/plugin-node-resolve": "^11.2.0", 19 | "@rollup/plugin-typescript": "^8.2.0", 20 | "@tsconfig/svelte": "^1.0.10", 21 | "postcss": "^8.2.6", 22 | "rollup": "^2.39.0", 23 | "rollup-plugin-css-only": "^3.1.0", 24 | "rollup-plugin-livereload": "^2.0.0", 25 | "rollup-plugin-string": "^3.0.0", 26 | "rollup-plugin-svelte": "^7.0.0", 27 | "rollup-plugin-svelte-hot": "^0.13.0", 28 | "rollup-plugin-terser": "^7.0.2", 29 | "rollup-plugin-web-worker-loader": "^1.5.0", 30 | "sass": "^1.32.7", 31 | "svelte": "^3.32.3", 32 | "svelte-materialify": "^0.3.5", 33 | "svelte-preprocess": "^4.6.9", 34 | "tslib": "^2.1.0", 35 | "typescript": "^4.1.5" 36 | }, 37 | "dependencies": { 38 | "@ts-stack/markdown": "^1.3.0", 39 | "@types/marked": "^1.2.1", 40 | "@typescript-eslint/eslint-plugin": "^4.15.1", 41 | "axios": "^0.21.1", 42 | "benz-amr-recorder": "^1.1.3", 43 | "marked": "^2.0.0", 44 | "sirv-cli": "^1.0.10", 45 | "web-worker-proxy": "^0.5.5" 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | OneUI 6 | 7 | 8 | 9 | 54 | 55 | 56 | 57 |
58 |
59 | 60 | 63 | 64 |

OneUI

65 |
66 |
67 | 68 | 69 | -------------------------------------------------------------------------------- /public/silksdk.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Steve-xmh/oneui/b3a985d4c48110f141bbd9b07f220650ee08ae1d/public/silksdk.wasm -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import svelte from 'rollup-plugin-svelte'; 2 | import commonjs from '@rollup/plugin-commonjs'; 3 | import resolve from '@rollup/plugin-node-resolve'; 4 | import livereload from 'rollup-plugin-livereload'; 5 | import { terser } from 'rollup-plugin-terser'; 6 | import css from 'rollup-plugin-css-only'; 7 | import typescript from '@rollup/plugin-typescript'; 8 | import webWorkerLoader from 'rollup-plugin-web-worker-loader'; 9 | import { preprocess } from './svelte.config'; 10 | 11 | const production = !process.env.ROLLUP_WATCH; 12 | 13 | function serve() { 14 | let server; 15 | 16 | function toExit() { 17 | if (server) server.kill(0); 18 | } 19 | 20 | return { 21 | writeBundle() { 22 | if (server) return; 23 | server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], { 24 | stdio: ['ignore', 'inherit', 'inherit'], 25 | shell: true 26 | }); 27 | 28 | process.on('SIGTERM', toExit); 29 | process.on('exit', toExit); 30 | } 31 | }; 32 | } 33 | 34 | export default { 35 | input: 'src/index.ts', 36 | external: ['AMR'], 37 | output: { 38 | sourcemap: true, 39 | format: 'iife', 40 | name: 'oneui', 41 | file: 'public/build/bundle.js', 42 | globals: { 43 | 'amr': 'AMR' 44 | } 45 | }, 46 | plugins: [ 47 | svelte({ 48 | preprocess, 49 | emitCss: false, 50 | compilerOptions: { 51 | dev: !production 52 | } 53 | }), 54 | // we'll extract any component CSS out into 55 | // a separate file - better for performance 56 | css({ output: 'bundle.css' }), 57 | // If you have external dependencies installed from 58 | // npm, you'll most likely need these plugins. In 59 | // some cases you'll need additional configuration - 60 | // consult the documentation for details: 61 | // https://github.com/rollup/plugins/tree/master/packages/commonjs 62 | resolve({ 63 | browser: true, 64 | dedupe: ['svelte'] 65 | }), 66 | commonjs(), 67 | typescript({ 68 | sourceMap: true, 69 | inlineSources: !production 70 | }), 71 | 72 | webWorkerLoader({ 73 | loadPath: 'build', 74 | inline: false 75 | }), 76 | 77 | // In dev mode, call `npm run start` once 78 | // the bundle has been generated 79 | !production && serve(), 80 | 81 | // Watch the `public` directory and refresh the 82 | // browser on changes when not in production 83 | !production && livereload('public'), 84 | 85 | // If we're building for production (npm run build 86 | // instead of npm run dev), minify 87 | production && terser() 88 | ], 89 | watch: { 90 | clearScreen: false 91 | } 92 | }; -------------------------------------------------------------------------------- /scripts/outputPublicAPI.js: -------------------------------------------------------------------------------- 1 | // Use it in devtools 2 | b = $$('article > h2') 3 | c = b.map(v => { 4 | const params = [] 5 | const results = [] 6 | if (v.nextElementSibling.nextElementSibling.localName === 'table') 7 | for (const row of v.nextElementSibling.nextElementSibling.tBodies[0].rows) { 8 | switch (row.cells.length) { 9 | case 4: { 10 | const [fieldEl, typeEl, defaultEl, descEl] = row.cells 11 | params.push({ 12 | field: fieldEl.innerText.trim(), 13 | type: typeEl.innerText.trim(), 14 | defaultValue: defaultEl.innerText.trim(), 15 | desc: descEl.innerText.trim(), 16 | }) 17 | break 18 | } 19 | case 3: { 20 | const [fieldEl, typeEl, descEl] = row.cells 21 | params.push({ 22 | field: fieldEl.innerText.trim(), 23 | type: typeEl.innerText.trim(), 24 | defaultValue: '', 25 | desc: descEl.innerText.trim(), 26 | }) 27 | break 28 | } 29 | } 30 | } 31 | if (v.nextElementSibling.nextElementSibling.nextElementSibling.nextElementSibling.localName === 'table') 32 | for (const row of v.nextElementSibling.nextElementSibling.nextElementSibling.nextElementSibling.tBodies[0].rows) { 33 | const [fieldEl, typeEl, descEl] = row.cells 34 | results.push({ 35 | field: fieldEl.innerText.trim(), 36 | type: typeEl.innerText.trim(), 37 | desc: descEl.innerText.trim(), 38 | }) 39 | } 40 | return { 41 | name: v.childNodes[1].innerText.trim(), 42 | desc: v.childNodes[2].nodeValue.trim(), 43 | params, 44 | results, 45 | } 46 | }) 47 | JSON.stringify(c) -------------------------------------------------------------------------------- /src/components/chat/MessageList.svelte: -------------------------------------------------------------------------------- 1 | 19 | 20 | 21 | 22 |
23 |
24 | {#if hasMessages} 25 | {#each messages as msg} 26 | 27 | {/each} 28 | {/if} 29 |
30 | 31 | 43 | -------------------------------------------------------------------------------- /src/components/message/AtMessage.svelte: -------------------------------------------------------------------------------- 1 | 5 |
6 | {message.data.text} 7 |
-------------------------------------------------------------------------------- /src/components/message/BFaceMessage.svelte: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/message/FaceMessage.svelte: -------------------------------------------------------------------------------- 1 | 14 | 15 | 21 | 22 | 30 | -------------------------------------------------------------------------------- /src/components/message/FileMessage.svelte: -------------------------------------------------------------------------------- 1 | 8 | 9 |
window.open(message.data.url)} 13 | > 14 | 15 |
16 |
{message.data.name}
17 |
18 | {getSizeString(message.data.size)} 19 |
20 |
21 |
22 | 23 | 34 | -------------------------------------------------------------------------------- /src/components/message/ImageMessage.svelte: -------------------------------------------------------------------------------- 1 | 8 | 9 | {#await message.data.detail} 10 | 11 | {:then url} 12 | imageViewer.show(url)} 17 | /> 18 | {:catch} 19 | 20 | {/await} 21 | 22 | 30 | -------------------------------------------------------------------------------- /src/components/message/JSONMessage.svelte: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/message/Message.svelte: -------------------------------------------------------------------------------- 1 | 23 | 24 | {#if $settings.allRaw || !(message.type in messages)} 25 | 26 | {:else} 27 | 28 | {/if} 29 | -------------------------------------------------------------------------------- /src/components/message/MessageBubble.svelte: -------------------------------------------------------------------------------- 1 | 12 | 13 |
14 | 22 |
23 |
24 | {#each messages as message, i (i)} 25 |
30 | {#if i === 0 && (userId in $users)} 31 |
{$users[userId].card || $users[userId].nickname}
36 | {/if} 37 | 38 |
39 | {/each} 40 |
41 |
42 | 43 | 103 | -------------------------------------------------------------------------------- /src/components/message/RawMessage.svelte: -------------------------------------------------------------------------------- 1 | 6 |
7 |
8 | {stringifyOne(message)} 9 |
10 |
RAW
11 |
12 | -------------------------------------------------------------------------------- /src/components/message/RecordMessage.svelte: -------------------------------------------------------------------------------- 1 | 55 | 56 | {#if message.data.detail} 57 | {#await message.data.detail} 58 | 59 | {:then source} 60 |
63 | 66 | 72 | 73 | {timeToString(Math.round(playbackPosition))}/{timeToString( 74 | Math.round(source.length) 75 | )} 76 | 77 |
78 | {:catch} 79 | 80 | {/await} 81 | {:else} 82 | 83 | {/if} 84 | 85 | 91 | -------------------------------------------------------------------------------- /src/components/message/ReplyMessage.svelte: -------------------------------------------------------------------------------- 1 | 7 | 8 |
9 | Reply:
10 | {#await message.data.detail} 11 | 12 | {:then result} 13 | {#if result} 14 | {#each result as msg} 15 | 16 | {/each} 17 | {:else} 18 | Failed to resolve reply detail. 19 | {/if} 20 | {/await} 21 |
22 | 23 | 28 | -------------------------------------------------------------------------------- /src/components/message/SelfMessage.svelte: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/message/TextMessage.svelte: -------------------------------------------------------------------------------- 1 | 7 | 8 |
9 | {#if $settings.markdown} 10 | {@html marked.parse(message.data.text)} 11 | {:else} 12 | {message.data.text} 13 | {/if} 14 |
15 | -------------------------------------------------------------------------------- /src/components/message/XMLMessage.svelte: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/settings/Settings.svelte: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | 20 | {l('oneui.settings')} 21 | 22 |
23 | 26 | settings.setSetting( 27 | 'theme', 28 | $settings.theme === Theme.Dark 29 | ? Theme.Light 30 | : Theme.Dark 31 | )} 32 | > 33 | {l('oneui.settings.darkmode')} 34 | 35 |
36 | 39 | settings.setSetting('markdown', !$settings.markdown)} 40 | > 41 | {l('oneui.settings.markdown')} 42 | 43 |
44 | 47 | settings.setSetting('allRaw', !$settings.allRaw)} 48 | > 49 | {l('oneui.settings.rawmessage')} 50 | 51 |
52 | 55 | settings.setSetting( 56 | 'faceType', 57 | $settings.faceType === CQFaceType.Dynamic 58 | ? CQFaceType.Static 59 | : CQFaceType.Dynamic 60 | )} 61 | > 62 | {l('oneui.settings.gifface')} 63 | 64 | 67 | settings.setSetting( 68 | 'hideFaceOutline', 69 | !$settings.hideFaceOutline 70 | )} 71 | > 72 | {l('oneui.settings.whitefacebackground')} 73 | 74 | 75 | 76 | 84 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /src/components/utils/ImageViewer.svelte: -------------------------------------------------------------------------------- 1 | 22 | 23 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 38 | -------------------------------------------------------------------------------- /src/custom.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'web-worker:*' { 2 | const WorkerFactory: new () => Worker; 3 | export default WorkerFactory; 4 | } 5 | -------------------------------------------------------------------------------- /src/i18n/en.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | 'oneui.connect.title': 'Connect to OneBot', 3 | 'oneui.connect.websocket.warning': 'You can use query url to use access token.', 4 | 'oneui.connect.websocket.field.url': 'Connect Url', 5 | 'oneui.connect.button.text': 'Connect', 6 | 7 | 'oneui.connect.http.warning': 'Warning: You can\'t receive events using HTTP.', 8 | 9 | 'oneui.settings': 'Settings', 10 | 'oneui.settings.darkmode': 'Dark Mode', 11 | 'oneui.settings.markdown': 'Enable Markdown (Expermantal)', 12 | 'oneui.settings.rawmessage': 'Show messages as raw message', 13 | 'oneui.settings.gifface': 'Use dynamic face image', 14 | 'oneui.settings.whitefacebackground': 'Use white background to hide dynamic face white outline', 15 | } -------------------------------------------------------------------------------- /src/i18n/index.ts: -------------------------------------------------------------------------------- 1 | import en from './en' 2 | import zhCN from './zh-cn' 3 | 4 | export type Translation = typeof en 5 | export type I18nTable = typeof i18nTable 6 | 7 | export const i18nTable: { [key: string]: Translation } = { 8 | en, 9 | 'zh-CN': zhCN 10 | } 11 | 12 | export default function l(id: keyof Translation, lang?: keyof I18nTable): string { 13 | const langs = lang ? [lang, 'en'] : navigator.languages 14 | for (let i = 0; i < langs.length; i++) { 15 | const thisLang = langs[i] 16 | if (thisLang in i18nTable) { 17 | if (id in i18nTable[thisLang]) { 18 | return i18nTable[thisLang][id] 19 | } 20 | } 21 | } 22 | console.warn('[OneUI-I18N]', 'Unknown translation id:', id, ', checked these languages: ', langs, i18nTable) 23 | return id 24 | } 25 | -------------------------------------------------------------------------------- /src/i18n/zh-cn.ts: -------------------------------------------------------------------------------- 1 | import type { Translation } from './index' 2 | 3 | const zhCN: Translation = { 4 | 'oneui.connect.title': '连接到 OneBot', 5 | 'oneui.connect.websocket.warning': '你可以使用请求 URL 来使用访问令牌。', 6 | 'oneui.connect.websocket.field.url': '连接地址', 7 | 'oneui.connect.button.text': '连接', 8 | 9 | 'oneui.connect.http.warning': '警告:HTTP 连接不支持消息事件,无法接收消息!', 10 | 11 | 'oneui.settings': '设置', 12 | 'oneui.settings.darkmode': '黑暗模式', 13 | 'oneui.settings.markdown': '启用 Markdown (实验性)', 14 | 'oneui.settings.rawmessage': '显示原始消息数据', 15 | 'oneui.settings.gifface': '使用动态图片表情', 16 | 'oneui.settings.whitefacebackground': '使用白色气泡掩盖动态表情白边', 17 | } 18 | 19 | export default zhCN 20 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import App from './App.svelte' 2 | 3 | document.body.innerHTML = '' 4 | 5 | const app = new App({ 6 | target: document.body, 7 | }) 8 | 9 | export default app 10 | -------------------------------------------------------------------------------- /src/onebot/messages.ts: -------------------------------------------------------------------------------- 1 | export enum PostType { 2 | Message = 'message', 3 | Notice = 'notice', 4 | Request = 'request', 5 | MetaEvent = 'meta_event', 6 | } 7 | 8 | export interface CQMessage { 9 | type: string, 10 | data: any 11 | } 12 | 13 | export interface BaseMessage { 14 | time: number 15 | self_id: number 16 | post_type: PostType 17 | } 18 | 19 | export enum MessageType { 20 | Private = 'private', 21 | Group = 'group' 22 | } 23 | 24 | export enum SubMessageType { 25 | // Only in private 26 | /** 私聊 - 好友会话 */ 27 | Friend = 'friend', 28 | /** 私聊 - 群临时会话 */ 29 | Group = 'group', 30 | /** 私聊 - 其他 */ 31 | Other = 'other', 32 | // Only in group 33 | /** 群聊 - 正常消息 */ 34 | Normal = 'normal', 35 | /** 群聊 - 匿名信息 */ 36 | Anonymous = 'anonymous', 37 | /** 群聊 - 系统提示 */ 38 | Notice = 'notice' 39 | } 40 | 41 | export interface Sender { 42 | user_id: number 43 | nickname: string 44 | sex: string 45 | age: number 46 | } 47 | 48 | export interface MessageMessage extends BaseMessage { 49 | post_type: PostType.Message 50 | message_type: MessageType.Private 51 | sub_type: SubMessageType 52 | message_id: number 53 | user_id: number 54 | message: string 55 | raw_message: string 56 | font: number 57 | sender: Sender 58 | } 59 | 60 | export interface GroupMessage extends BaseMessage { 61 | post_type: PostType.Message 62 | message_type: MessageType.Group 63 | 64 | group_id: number 65 | anonymous: number 66 | 67 | sub_type: SubMessageType 68 | message_id: number 69 | user_id: number 70 | message: string 71 | raw_message: string 72 | font: number 73 | sender: Sender 74 | } 75 | -------------------------------------------------------------------------------- /src/stores/contact.ts: -------------------------------------------------------------------------------- 1 | import { writable } from "svelte/store" 2 | import { MessageType } from "../onebot/messages" 3 | 4 | export function getContactID(id: number, isGroup = false): string { 5 | if (isGroup) { 6 | return 'G' + id.toString() 7 | } else { 8 | return 'U' + id.toString() 9 | } 10 | } 11 | 12 | export function getContactType(cid: string): MessageType { 13 | switch (cid[0]) { 14 | case 'U': 15 | return MessageType.Private 16 | case 'G': 17 | return MessageType.Group 18 | default: 19 | throw new TypeError(`${cid} is not a vaild contact id`) 20 | } 21 | } 22 | 23 | export function getUserID(cid: string): number { 24 | return parseInt(cid.slice(1)) 25 | } 26 | 27 | function createContactStore() { 28 | const { subscribe, set } = writable('') 29 | return { 30 | subscribe, 31 | close: () => set(''), 32 | switch: (cid: string) => set(cid) 33 | } 34 | } 35 | 36 | export const contact = createContactStore() 37 | -------------------------------------------------------------------------------- /src/stores/face.ts: -------------------------------------------------------------------------------- 1 | import { writable } from "svelte/store"; 2 | 3 | export enum CQFaceType { 4 | /** 使用静态 png 表情 */ 5 | Static, 6 | /** 使用动态 gif 表情 */ 7 | Dynamic 8 | } 9 | 10 | function createFaceStore() { 11 | const { subscribe, set, update } = writable(CQFaceType.Static) 12 | return { 13 | subscribe, 14 | useStatic: () => set(CQFaceType.Static), 15 | useDynamic: () => set(CQFaceType.Dynamic), 16 | set: (value: CQFaceType) => set(value) 17 | } 18 | } 19 | 20 | export const faceType = createFaceStore() 21 | -------------------------------------------------------------------------------- /src/stores/messages.ts: -------------------------------------------------------------------------------- 1 | import { writable } from "svelte/store" 2 | import { onebot } from "../onebot" 3 | import type { CQMessage } from "../onebot/messages" 4 | import { parse } from "../utils/cqcode" 5 | import { decode, makeAudioSource } from "../utils/audio" 6 | import { getUserID } from "./contact" 7 | 8 | interface Message { 9 | userId: number 10 | rawMessage: string 11 | messages: CQMessage[] 12 | } 13 | 14 | type MessageDatabase = { 15 | [key: string]: Message[] 16 | } 17 | 18 | async function resolveReply(cqMsg: CQMessage) { 19 | const reply = await onebot.getMessageByID(cqMsg.data.id) 20 | console.log('Resolved Reply', cqMsg, reply) 21 | if (reply.status === 'ok') { 22 | return parse(reply.data.raw_message).map(v => { 23 | if (v.type === 'reply') { 24 | v.data.detail = resolveReply(v) 25 | } 26 | return v 27 | }) 28 | } else { 29 | return false 30 | } 31 | } 32 | 33 | function createMessageDB() { 34 | const { subscribe, set, update } = writable({} as MessageDatabase) 35 | 36 | return { 37 | subscribe, 38 | addMessage: (contactId: string, raw_message: string, senderId?: number) => update(v => { 39 | if (!(contactId in v)) { 40 | v[contactId] = [] 41 | } 42 | const userId = senderId || getUserID(contactId) 43 | const cqmsg = parse(raw_message).map(v => { 44 | // Post process message 45 | if (v.type === 'reply') { 46 | v.data.detail = resolveReply(v) 47 | } else if (v.type === 'image') { 48 | v.data.detail = Promise.resolve(v.data.url) 49 | } else if (v.type === 'record') { 50 | v.data.detail = (async () => { 51 | const arraybuf = await (async () => { 52 | try { 53 | const result = await fetch(v.data.file) 54 | return await result.arrayBuffer() 55 | } catch { 56 | // Try cors anywhere 57 | const result = await fetch('https://cors-anywhere.herokuapp.com/' + v.data.file) 58 | return await result.arrayBuffer() 59 | } 60 | })(); 61 | try { 62 | return makeAudioSource(await decode(new Uint8Array(arraybuf))) 63 | } catch (err) { 64 | console.error('Decode Error:', err) 65 | throw err 66 | } 67 | })() 68 | } 69 | return v 70 | }) 71 | if (v[contactId].length > 0) { 72 | const lastMsg = v[contactId][v[contactId].length - 1] 73 | if (lastMsg.userId === userId) { 74 | lastMsg.rawMessage += '\n' + raw_message 75 | lastMsg.messages.push(...cqmsg) 76 | } else { 77 | v[contactId].push({ 78 | rawMessage: raw_message, 79 | messages: cqmsg, 80 | userId 81 | }) 82 | } 83 | } else { 84 | v[contactId].push({ 85 | rawMessage: raw_message, 86 | messages: cqmsg, 87 | userId 88 | }) 89 | } 90 | console.log('[MessageDB]', 'Added', contactId, raw_message) 91 | return v 92 | }), 93 | reset: () => set({}) 94 | } 95 | } 96 | 97 | export const messageDB = createMessageDB() 98 | -------------------------------------------------------------------------------- /src/stores/self.ts: -------------------------------------------------------------------------------- 1 | import { writable } from "svelte/store"; 2 | 3 | export interface SelfData { 4 | userId: number 5 | userName: string 6 | friends: Friend[] 7 | groups: Group[] 8 | } 9 | 10 | export interface Friend { 11 | user_id: number 12 | nickname: string 13 | remark: string 14 | } 15 | 16 | export interface Group { 17 | group_id: number 18 | group_name: string 19 | member_count: number 20 | max_member_count: number 21 | } 22 | 23 | function createSelfStore() { 24 | const selfData: SelfData = { 25 | userId: 0, 26 | userName: '', 27 | friends: [], 28 | groups: [] 29 | } 30 | const { subscribe, set, update } = writable(selfData) 31 | return { 32 | subscribe, 33 | setFriends: (friends: Friend[]) => update(v => { 34 | v.friends = friends 35 | return v 36 | }), 37 | setGroups: (groups: Group[]) => update(v => { 38 | v.groups = groups 39 | return v 40 | }), 41 | setSelf: (userId: number, userName: string) => update(v => { 42 | v.userId = userId 43 | v.userName = userName 44 | return v 45 | }), 46 | reset: () => set({ 47 | userId: 0, 48 | userName: '', 49 | friends: [], 50 | groups: [] 51 | }) 52 | } 53 | } 54 | 55 | export const selfData = createSelfStore() 56 | -------------------------------------------------------------------------------- /src/stores/settings.ts: -------------------------------------------------------------------------------- 1 | import { writable } from "svelte/store"; 2 | import { CQFaceType } from "./face"; 3 | import { Theme } from "./theme"; 4 | 5 | interface SettingsObject { 6 | [key: string]: any 7 | } 8 | 9 | const defaultSettings: SettingsObject = { 10 | markdown: false, 11 | allRaw: false, 12 | hideFaceOutline: false, 13 | faceType: CQFaceType.Static, 14 | theme: Theme.Dark 15 | } 16 | 17 | const prefix = 'setting.' 18 | 19 | function collectSettings() { 20 | const result: SettingsObject = {} 21 | for (let i = 0; i < localStorage.length; i++) { 22 | const key = localStorage.key(i) 23 | if (key && key.startsWith(prefix)) { 24 | const storeKey = key.substring(prefix.length) 25 | result[storeKey] = JSON.parse(localStorage.getItem(key) as string) 26 | } 27 | } 28 | return result 29 | } 30 | 31 | function updateSettings(value: SettingsObject) { 32 | for (const key in value) { 33 | if (key in defaultSettings && value[key] !== defaultSettings[key]) { 34 | localStorage.setItem(prefix + key, JSON.stringify(value[key])) 35 | } else if (localStorage.getItem(prefix + key)) { 36 | localStorage.removeItem(prefix + key) 37 | } 38 | } 39 | } 40 | 41 | function createSettingsStore() { 42 | const { subscribe, set, update } = writable(Object.assign(Object.assign({}, defaultSettings), collectSettings())) 43 | return { 44 | subscribe, 45 | reset: () => { 46 | const value = Object.assign({}, defaultSettings) 47 | set(value) 48 | updateSettings(value) 49 | }, 50 | setSetting: (key: string, value: any) => update(v => { 51 | v[key] = value 52 | updateSettings(v) 53 | return v 54 | }) 55 | } 56 | } 57 | 58 | export const settings = createSettingsStore() 59 | -------------------------------------------------------------------------------- /src/stores/theme.ts: -------------------------------------------------------------------------------- 1 | export enum Theme { 2 | Light, 3 | Dark 4 | } 5 | -------------------------------------------------------------------------------- /src/stores/users.ts: -------------------------------------------------------------------------------- 1 | import { writable } from "svelte/store" 2 | 3 | export interface User { 4 | nickname: string 5 | } 6 | 7 | export type Users = { [userid: string]: User } 8 | 9 | function createUsersStore() { 10 | const { subscribe, set, update } = writable({ 11 | 1: { 12 | nickname: 'Test User' 13 | } 14 | } as Users) 15 | return { 16 | subscribe, 17 | set, 18 | update, 19 | setUser: (userid: number, userdata: User) => update(v => { 20 | v[userid] = userdata 21 | return v 22 | }) 23 | } 24 | } 25 | 26 | export const users = createUsersStore() 27 | -------------------------------------------------------------------------------- /src/utils/amr.d.ts: -------------------------------------------------------------------------------- 1 | declare module "amr" { 2 | export interface AMRDecoderOptions { 3 | benchmark: boolean 4 | } 5 | 6 | export default class AMR { 7 | constructor(options?: Partial) 8 | decode(bitstream: string | Uint8Array): Float32Array 9 | close() 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/utils/audio-worker.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * WebWorker side of audio decoder. 4 | */ 5 | 6 | importScripts('../amrnb.min.js', '../silksdk.js') 7 | 8 | import { proxy } from 'web-worker-proxy' 9 | 10 | import type { EmscriptenModule } from './silksdk' 11 | 12 | import genUid from './uid' 13 | 14 | let SilkSDK: EmscriptenModule = self as unknown as EmscriptenModule 15 | 16 | SilkSDK.print = (a: string) => console.log('[OneUI-Audio]', a) 17 | SilkSDK.printErr = (a: string) => console.error('[OneUI-Audio]', a) 18 | 19 | function decodeAMR (data: Uint8Array) { 20 | SilkSDK.print('Decoding AMR audio') 21 | const startTime = Date.now() 22 | const decoder = new (self as unknown as any).AMR({}) 23 | const result = decoder.decode(data) 24 | decoder.close() 25 | SilkSDK.print(`Finished decoding AMR audio in ${Date.now() - startTime} ms`) 26 | return result 27 | } 28 | 29 | function decodeSilkV3 (data: Uint8Array) { 30 | if (!SilkSDK) { 31 | throw new Error('SilkSDK is not ready.') 32 | } 33 | const startTime = Date.now() 34 | SilkSDK.print('Decoding SilkV3 audio') 35 | const sourceFile = genUid() + '.bit' 36 | const destFile = genUid() + '.pcm' 37 | SilkSDK.FS.writeFile(sourceFile, data) 38 | SilkSDK.callMain([sourceFile, destFile]) 39 | const result = SilkSDK.FS.readFile(destFile) 40 | SilkSDK.FS.unlink(sourceFile) 41 | SilkSDK.FS.unlink(destFile) 42 | const a = new Float32Array(result.length) 43 | for (let i = 0; i < a.length; i++) { 44 | a[i] = result[i] / 32768 45 | } 46 | SilkSDK.print(`Finished decoding SilkV3 audio in ${Date.now() - startTime} ms`) 47 | return a 48 | } 49 | 50 | const workerProxy = { 51 | decodeAMR, 52 | decodeSilkV3 53 | } 54 | 55 | type UnpackedPromise = T extends Promise ? U : T 56 | type GenericFunction = (...args: TS) => R 57 | type Promisify = { 58 | [K in keyof T]: T[K] extends GenericFunction 59 | ? (...args: TS) => Promise> 60 | : never 61 | } 62 | 63 | export type DecodeWorkerProxy = Promisify 64 | 65 | proxy(workerProxy) 66 | SilkSDK.print('WebWorker is ready!') 67 | SilkSDK.print('OneUI-Audio is ready!') 68 | -------------------------------------------------------------------------------- /src/utils/audio.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * A simple SLIKv3/AMR audio decoder. 4 | */ 5 | import DecodeWorker from 'web-worker:./audio-worker.ts' 6 | import { create } from 'web-worker-proxy' 7 | import type { DecodeWorkerProxy } from './audio-worker' 8 | 9 | const decodeWorker = create(new DecodeWorker()) as DecodeWorkerProxy; 10 | 11 | function isEqual (a: Uint8Array, b: Uint8Array) { 12 | if (a.length === b.length) { 13 | for (let i = 0; i < a.length; i++) { 14 | if (a[i] !== b[i]) return false 15 | } 16 | return true 17 | } else { 18 | return false 19 | } 20 | } 21 | 22 | // #!SILK_V3 23 | const silkHeader = new Uint8Array([0x23, 0x21, 0x53, 0x49, 0x4C, 0x4B, 0x5F, 0x56, 0x33]) 24 | // #!AMR\n 25 | const amrHeader = new Uint8Array([0x23, 0x21, 0x41, 0x4d, 0x52, 0x0a]) 26 | 27 | function isSLIKAudio (data: Uint8Array): number { 28 | if (data.length < silkHeader.length) { 29 | return 0 30 | } else if (data[0] === 0x02) { 31 | if (data.length < silkHeader.length + 1) { 32 | return 0 33 | } else { 34 | return isEqual(data.subarray(1, 1 + silkHeader.length), silkHeader) ? silkHeader.length + 1 : 0 35 | } 36 | } else { 37 | return isEqual(data.subarray(0, silkHeader.length), silkHeader) ? silkHeader.length : 0 38 | } 39 | } 40 | 41 | function isAMRAudio (data: Uint8Array): boolean { 42 | if (data.length < silkHeader.length) { 43 | return false 44 | } else { 45 | return isEqual(data.subarray(0, amrHeader.length), amrHeader) 46 | } 47 | } 48 | 49 | /** 50 | * Decode silkv3/amr audio, return raw pcm wave array (s16le, 24000 rate, 1 channel) 51 | * @param data The raw silk data 52 | */ 53 | export async function decode (data: Uint8Array): Promise { 54 | if (isAMRAudio(data)) { 55 | return { 56 | wave: await decodeWorker.decodeAMR(data), 57 | type: 'amr' 58 | } 59 | } else if (isSLIKAudio(data) !== 0) { 60 | return { 61 | wave: await decodeWorker.decodeSilkV3(data), 62 | type: 'silk' 63 | } 64 | } else { 65 | throw new Error("Can't detect silk/amr audio header, not a correct silk/amr audio.") 66 | } 67 | } 68 | 69 | const ctx = new AudioContext() 70 | 71 | export interface PCMSource { 72 | length: number 73 | rate: number 74 | source: Float32Array 75 | ctx: AudioContext 76 | } 77 | 78 | export interface DecodeResult { 79 | wave: Float32Array 80 | type: 'silk' | 'amr' 81 | } 82 | 83 | const rate = { 84 | silk: 24000, 85 | amr: 8000 86 | } 87 | 88 | export function makeAudioSource(wave: DecodeResult): PCMSource { 89 | return { 90 | length: wave.wave.length / rate[wave.type], 91 | source: wave.wave, 92 | rate: rate[wave.type], 93 | ctx 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/utils/base64.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * Base64 convertions, from https://stackoverflow.com/a/63526839/14123552 4 | */ 5 | 6 | const encoder = new TextEncoder(); 7 | const decoder = new TextDecoder(); 8 | const base64Table = encoder.encode('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='); 9 | export function toBase64(dataArr: Uint8Array): string { 10 | let padding = dataArr.byteLength % 3; 11 | let outputCtr = 0; 12 | const len = dataArr.byteLength - padding; 13 | padding = padding > 0 ? (3 - padding) : 0; 14 | const outputLen = ((len/3) * 4) + (padding > 0 ? 4 : 0); 15 | const output = new Uint8Array(outputLen); 16 | for(var i=0; i> 18]; 19 | output[outputCtr++] = base64Table[(buffer >> 12) & 0x3F]; 20 | output[outputCtr++] = base64Table[(buffer >> 6) & 0x3F]; 21 | output[outputCtr++] = base64Table[buffer & 0x3F]; 22 | } 23 | if (padding == 1) { 24 | var buffer = ((dataArr[len] & 0xFF) << 8) | (dataArr[len+1] & 0xFF); 25 | output[outputCtr++] = base64Table[buffer >> 10]; 26 | output[outputCtr++] = base64Table[(buffer >> 4) & 0x3F]; 27 | output[outputCtr++] = base64Table[(buffer << 2) & 0x3F]; 28 | output[outputCtr++] = base64Table[64]; 29 | } else if (padding == 2) { 30 | var buffer = dataArr[len] & 0xFF; 31 | output[outputCtr++] = base64Table[buffer >> 2]; 32 | output[outputCtr++] = base64Table[(buffer << 4) & 0x3F]; 33 | output[outputCtr++] = base64Table[64]; 34 | output[outputCtr++] = base64Table[64]; 35 | } 36 | 37 | var ret = decoder.decode(output); 38 | return ret; 39 | } 40 | -------------------------------------------------------------------------------- /src/utils/cqcode.ts: -------------------------------------------------------------------------------- 1 | import type { CQMessage } from "../onebot/messages" 2 | 3 | const cqRegExp = /^\[CQ:(?\w+?)(?(?:,(?:\w+?)=(?:[^\[\]\$\,]+?))*)?\]$/ 4 | 5 | export function parseOne(cqcode: string): CQMessage { 6 | const matchResult = cqcode.match(cqRegExp) 7 | if (matchResult && matchResult.groups) { 8 | const data: { [_: string]: string } = {} 9 | if (typeof matchResult.groups.params === 'string') { 10 | const params = matchResult.groups.params.substring(1).split(',') 11 | for (const paramPair of params) { 12 | const equalPos = paramPair.indexOf('=') 13 | const key = paramPair.substring(0, equalPos) 14 | const value = paramPair.substring(equalPos + 1) 15 | data[key] = unescapeString(value) 16 | } 17 | } 18 | return { 19 | type: matchResult.groups.type, 20 | data 21 | } 22 | } else { 23 | throw new Error('Input isn\'t a single cqcode.') 24 | } 25 | } 26 | 27 | export function parse(cqcode: string): CQMessage[] { 28 | const result = [] 29 | let str = cqcode 30 | while (str.length) { 31 | const nextLeft = str.search(/\[CQ:/) 32 | if (nextLeft === -1) { // No more cqcode, push them as text 33 | result.push({ 34 | type: 'text', 35 | data: { 36 | text: unescapeString(str) 37 | } 38 | }) 39 | str = '' 40 | } else { 41 | if (nextLeft > 0) { 42 | result.push({ 43 | type: 'text', 44 | data: { text: unescapeString(str.substring(0, nextLeft)) } 45 | }) 46 | } 47 | const nextRight = str.search(']') 48 | const cqcode = str.substring(nextLeft, nextRight + 1) 49 | result.push(parseOne(cqcode)) 50 | str = str.substring(nextRight + 1) 51 | } 52 | } 53 | return result 54 | } 55 | 56 | export function tryParse(cqcode: string): CQMessage[] { 57 | try { 58 | return parse(cqcode) 59 | } catch { 60 | return [] 61 | } 62 | } 63 | 64 | const cqEscapes: { [char: string]: string } = { 65 | '&': '&', 66 | ',': ',', 67 | '[': '[', 68 | ']': ']' 69 | } 70 | 71 | export function escapeString(data: string) { 72 | let result = data 73 | for (const key in cqEscapes) { 74 | result = result.replaceAll(key, cqEscapes[key]) 75 | } 76 | return result 77 | } 78 | 79 | export function unescapeString(data: string) { 80 | let result = data 81 | for (const key in cqEscapes) { 82 | result = result.replaceAll(cqEscapes[key], key) 83 | } 84 | return result 85 | } 86 | 87 | export function stringifyOne(cqcode: CQMessage) { 88 | return `[CQ:${cqcode.type}${cqcode.data ? `,${ 89 | Object.entries(cqcode.data).map(v => { 90 | if (!['string', 'number'].includes(typeof v[1])) return '' 91 | let a = v[0] + '=' + escapeString(v[1] as string) 92 | return a 93 | }).join(',') 94 | }` : ''}]` 95 | } 96 | 97 | export function stringify(cqcodes: CQMessage[]) { 98 | const result = [] 99 | for (const cqcode of cqcodes) { 100 | if (cqcode.type === 'text' && cqcode.data?.text) { 101 | result.push(cqcode.data.text) 102 | } else { 103 | result.push(stringifyOne(cqcode)) 104 | } 105 | } 106 | return result.join('') 107 | } 108 | -------------------------------------------------------------------------------- /src/utils/file-icons.ts: -------------------------------------------------------------------------------- 1 | import * as mdi from '@mdi/js' 2 | 3 | const fileIcons: { [_: string]: string } = { 4 | // Common file 5 | '.txt': mdi.mdiTextBox, 6 | 7 | '.png': mdi.mdiImage, 8 | '.webp': mdi.mdiImage, 9 | '.jpg': mdi.mdiImage, 10 | '.jpeg': mdi.mdiImage, 11 | '.gif': mdi.mdiImage, 12 | '.bmp': mdi.mdiImage, 13 | '.tif': mdi.mdiImage, 14 | '.tiff': mdi.mdiImage, 15 | '.heif': mdi.mdiImage, 16 | '.indd': mdi.mdiImage, 17 | '.eps': mdi.mdiImage, 18 | '.raw': mdi.mdiImage, 19 | '.cr2': mdi.mdiImage, 20 | '.nef': mdi.mdiImage, 21 | '.orf': mdi.mdiImage, 22 | '.sr2': mdi.mdiImage, 23 | '.psd': mdi.mdiImage, 24 | '.svg': mdi.mdiImage, 25 | '.ai': mdi.mdiImage, 26 | 27 | '.doc': mdi.mdiFileWordBox, 28 | '.docx': mdi.mdiFileWordBox, 29 | '.ppt': mdi.mdiFilePowerpointBox, 30 | '.pptx': mdi.mdiFilePowerpointBox, 31 | '.xls': mdi.mdiFileExcelBox, 32 | '.xlsx': mdi.mdiFileExcelBox, 33 | 34 | '.pdf': mdi.mdiPdfBox, 35 | 36 | '.zip': mdi.mdiZipBox, 37 | '.rar': mdi.mdiZipBox, 38 | '.gz': mdi.mdiZipBox, 39 | '.tar': mdi.mdiZipBox, 40 | '.7z': mdi.mdiZipBox, 41 | 42 | // Programing file 43 | '.c': mdi.mdiLanguageC, 44 | '.cc': mdi.mdiLanguageC, 45 | '.cpp': mdi.mdiLanguageCpp, 46 | '.h': mdi.mdiLanguageC, 47 | '.hpp': mdi.mdiLanguageCpp, 48 | 49 | '.js': mdi.mdiLanguageJavascript, 50 | '.jsm': mdi.mdiLanguageJavascript, 51 | '.ts': mdi.mdiLanguageJavascript, 52 | 53 | '.cs': mdi.mdiLanguageCsharp, 54 | 55 | '.css': mdi.mdiLanguageCss3, 56 | '.scss': mdi.mdiLanguageCss3, 57 | '.sass': mdi.mdiLanguageCss3, 58 | '.styl': mdi.mdiLanguageCss3, 59 | 60 | '.java': mdi.mdiLanguageJava, 61 | '.kt': mdi.mdiLanguageKotlin, 62 | 63 | '.lua': mdi.mdiLanguageLua, 64 | 65 | '.html': mdi.mdiLanguageHtml5, 66 | '.htm': mdi.mdiLanguageHtml5, 67 | 68 | '.md': mdi.mdiLanguageMarkdown, 69 | 70 | '.php': mdi.mdiLanguagePhp, 71 | 72 | '.py': mdi.mdiLanguagePython, 73 | '.pyi': mdi.mdiLanguagePython, 74 | '.pyc': mdi.mdiLanguagePython, 75 | '.pyd': mdi.mdiLanguagePython, 76 | '.pyo': mdi.mdiLanguagePython, 77 | '.pyw': mdi.mdiLanguagePython, 78 | '.pyz': mdi.mdiLanguagePython, 79 | 80 | '.f': mdi.mdiLanguageFortran, 81 | '.for': mdi.mdiLanguageFortran, 82 | '.f90': mdi.mdiLanguageFortran, 83 | '.f95': mdi.mdiLanguageFortran, 84 | 85 | '.go': mdi.mdiLanguageGo, 86 | 87 | '.hs': mdi.mdiLanguageHaskell, 88 | '.lhs': mdi.mdiLanguageHaskell, 89 | 90 | '.rs': mdi.mdiLanguageRust, 91 | '.rb': mdi.mdiLanguageRuby, 92 | 93 | '.swift': mdi.mdiLanguageSwift, 94 | } 95 | 96 | export function getFileIconPath(filename: string): string { 97 | const ext = filename.substring(filename.lastIndexOf('.')) 98 | if (ext in fileIcons) { 99 | return fileIcons[ext] 100 | } 101 | return mdi.mdiFile 102 | } 103 | -------------------------------------------------------------------------------- /src/utils/logo.ts: -------------------------------------------------------------------------------- 1 | export const logoSvg = `` 2 | 3 | export const logoPath = 'M0 1C0 0.447715 0.447715 0 1 0H10C10.5523 0 11 0.447715 11 1C11 1.55228 10.5523 2 10 2H2V22H10C10.5523 22 11 22.4477 11 23C11 23.5523 10.5523 24 10 24H1C0.447715 24 0 23.5523 0 23V1ZM13 1C13 0.447715 13.4477 0 14 0H23C23.5523 0 24 0.447715 24 1V10C24 10.5523 23.5523 11 23 11C22.4477 11 22 10.5523 22 10V2H14C13.4477 2 13 1.55228 13 1ZM10.3827 5.07612C10.7564 5.2309 11 5.59554 11 6V18C11 18.5523 10.5523 19 10 19C9.44771 19 9 18.5523 9 18V8.41421L7.70711 9.70711C7.31658 10.0976 6.68342 10.0976 6.29289 9.70711C5.90237 9.31658 5.90237 8.68342 6.29289 8.29289L9.29289 5.29289C9.57889 5.0069 10.009 4.92134 10.3827 5.07612ZM13 18V6C13 5.44772 13.4477 5 14 5C14.5523 5 15 5.44772 15 6V15.5858L16.2929 14.2929C16.6834 13.9024 17.3166 13.9024 17.7071 14.2929C18.0976 14.6834 18.0976 15.3166 17.7071 15.7071L14.7071 18.7071C14.4211 18.9931 13.991 19.0787 13.6173 18.9239C13.2436 18.7691 13 18.4045 13 18ZM20.2929 14.2929C20.6834 13.9024 21.3166 13.9024 21.7071 14.2929L24.7071 17.2929C24.8946 17.4804 25 17.7348 25 18V21C25 21.2652 24.8946 21.5196 24.7071 21.7071L24.4142 22L31.7071 29.2929C32.0976 29.6834 32.0976 30.3166 31.7071 30.7071L30.7071 31.7071C30.3166 32.0976 29.6834 32.0976 29.2929 31.7071L22 24.4142L21.7071 24.7071C21.5196 24.8946 21.2652 25 21 25H18C17.7348 25 17.4804 24.8946 17.2929 24.7071L14.2929 21.7071C13.9024 21.3166 13.9024 20.6834 14.2929 20.2929L15.2929 19.2929C15.6834 18.9024 16.3166 18.9024 16.7071 19.2929L18.9142 21.5H20.0858L21.5 20.0858V18.9142L19.2929 16.7071C18.9024 16.3166 18.9024 15.6834 19.2929 15.2929L20.2929 14.2929Z' -------------------------------------------------------------------------------- /src/utils/size.ts: -------------------------------------------------------------------------------- 1 | const units = [ 2 | 'B', 3 | 'KB', 4 | 'MB', 5 | 'GB', 6 | 'TB', 7 | 'PB', 8 | 'EB', 9 | 'ZB', 10 | 'YB', 11 | ] 12 | 13 | export function getSizeString(size: number): string { 14 | let tmp = Math.ceil(size) 15 | let unit = units[0] 16 | for (let i = 1; i < units.length; i++) { 17 | if (tmp < 1024) break 18 | tmp /= 1024 19 | unit = units[i] 20 | } 21 | return tmp.toFixed(2) + unit 22 | } 23 | -------------------------------------------------------------------------------- /src/utils/uid.ts: -------------------------------------------------------------------------------- 1 | 2 | const words = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' 3 | 4 | export default function genUid(length = 16): string { 5 | let result = '' 6 | for (let i = 0; i < length; i++) { 7 | const r = Math.floor(Math.random() * words.length) 8 | result += words[r] 9 | } 10 | return result 11 | } 12 | -------------------------------------------------------------------------------- /svelte.config.js: -------------------------------------------------------------------------------- 1 | import sveltePreprocess from 'svelte-preprocess'; 2 | 3 | const production = !process.env.ROLLUP_WATCH; 4 | 5 | export const preprocess = sveltePreprocess({ 6 | scss: { 7 | includePaths: ['theme'], 8 | }, 9 | typescript: true, 10 | sourceMap: !production 11 | }) -------------------------------------------------------------------------------- /theme/_material-theme.scss: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/svelte/tsconfig.json", 3 | "compilerOptions": { 4 | "target": "es6", 5 | "lib": ["esnext", "dom", "WebWorker.ImportScripts"], 6 | "alwaysStrict": true, 7 | "strict": true, 8 | }, 9 | "include": ["src/**/*"], 10 | "exclude": ["node_modules/*", "__sapper__/*", "public/*"] 11 | } --------------------------------------------------------------------------------