Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ Thumbs.db
.cache
*.tsbuildinfo
*.tgz
.claude
.claude
.emsdk
51 changes: 51 additions & 0 deletions mbelib-wasm/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash
# Build mbelib as WASM module for BrowSDR DSD decoder.
#
# Prerequisites: Emscripten SDK (emcc) must be in PATH.
# Install: https://emscripten.org/docs/getting_started/downloads.html
#
# Usage: cd mbelib-wasm && bash build.sh
#
# Output: ../public/lib/mbelib/mbelib.js + mbelib.wasm

set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
OUT_DIR="$SCRIPT_DIR/../public/lib/mbelib"
MBELIB_DIR="$SCRIPT_DIR/mbelib"

# Clone mbelib if not present
if [ ! -d "$MBELIB_DIR" ]; then
echo "Downloading mbelib source..."
curl -sL "https://github.com/szechyjs/mbelib/archive/9a04ed5c78176a9965f3d43f7aa1b1f5330e771f.tar.gz" | tar xz -C "$SCRIPT_DIR"
mv "$SCRIPT_DIR/mbelib-9a04ed5c78176a9965f3d43f7aa1b1f5330e771f" "$MBELIB_DIR"
echo "mbelib source downloaded."
fi

mkdir -p "$OUT_DIR"

echo "Building mbelib WASM..."
emcc -O3 \
-s WASM=1 \
-s MODULARIZE=1 \
-s EXPORT_NAME='MbelibModule' \
-s EXPORTED_FUNCTIONS='["_mbelib_init","_mbelib_reset","_mbelib_decode_ambe","_mbelib_decode_imbe","_mbelib_get_err_str","_mbelib_get_errs","_mbelib_get_errs2","_malloc","_free"]' \
-s EXPORTED_RUNTIME_METHODS='["ccall","cwrap","getValue","setValue","UTF8ToString","HEAPF32","HEAP8"]' \
-s ALLOW_MEMORY_GROWTH=1 \
-s INITIAL_MEMORY=1048576 \
-s ENVIRONMENT='web,worker' \
-s FILESYSTEM=0 \
-s ASSERTIONS=0 \
-I"$MBELIB_DIR" \
-o "$OUT_DIR/mbelib.js" \
"$SCRIPT_DIR/wrapper.c" \
"$MBELIB_DIR/ambe3600x2400.c" \
"$MBELIB_DIR/ambe3600x2450.c" \
"$MBELIB_DIR/ecc.c" \
"$MBELIB_DIR/imbe7100x4400.c" \
"$MBELIB_DIR/imbe7200x4400.c" \
"$MBELIB_DIR/mbelib.c"

echo "Build complete: $OUT_DIR/mbelib.js + mbelib.wasm"
echo "File sizes:"
ls -lh "$OUT_DIR"/mbelib.*
4 changes: 4 additions & 0 deletions mbelib-wasm/mbelib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.[ao]
*.so*
*.dylib
build
13 changes: 13 additions & 0 deletions mbelib-wasm/mbelib/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
language: c

compiler:
- gcc

before_script:
- mkdir build
- cd build
- cmake ..

script:
- make
- make test
52 changes: 52 additions & 0 deletions mbelib-wasm/mbelib/CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
1.3.0:
Initial DSTAR AMBE support
Fixed random number generator
Several bug fixes and optimizations

1.2.5 Use CMake:
The cross platform building was getting hard to maintain,
removed Makefile in favor of CMake.

1.2.4 Fixed bugs:
Makefile cleanup
Readme file improvements
fix golayMatrix
bug in imbe7100x4400

1.2.3 Fixed bugs:
Cik array in mbe_decodeAmbe2250Parms was too small

1.2.2 Fixed bugs:
uninitialized variable in SpectralAmpEnhance()

1.2.1 New Features:

Improved unvoiced speech synthesis

Fixed bugs:
bug in spectralAmpEnhance()

1.2 New features:
Support for imbe7100x4400 vocoder
Improved audio quality

Fixed bugs:
error in hamming ecc

1.1 New features:
new synthesizer functions with floating point output buffer.
original short output buffer function stubs for compatibility.
audio gain and clipping is no longer done during synthesis
except within the compatibility functions.

1.0.2 Fixed bugs:
fixed several problems in synthesizer causing clicks
reduced error -> repeat thresholds for reduced noise bursts
ambe3600x2250 now correctly handles "Silence" frames
ambe Tone and Erasure frames are now indicated with T and E in errorbars

1.0.1 Fixed bugs:
cur_mp->repeat was not being copied to prev_mp
logic to check for bad mbe frames was incorrect

1.0 First release
56 changes: 56 additions & 0 deletions mbelib-wasm/mbelib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
project(mbe)
cmake_minimum_required(VERSION 2.6)

if(MSVC)
# needed for M_PI macro
add_definitions(-D_USE_MATH_DEFINES)
endif()

FILE(GLOB SRCS *.c)

include_directories("${PROJECT_SOURCE_DIR}")

ADD_LIBRARY(mbe-static STATIC ${SRCS})
ADD_LIBRARY(mbe-shared SHARED ${SRCS})
if(NOT WIN32)
TARGET_LINK_LIBRARIES(mbe-static m)
TARGET_LINK_LIBRARIES(mbe-shared m)
endif()

include(GNUInstallDirs)

set_target_properties(mbe-static mbe-shared
PROPERTIES
OUTPUT_NAME mbe
VERSION 1.3
SOVERSION 1
INSTALL_NAME_DIR ${CMAKE_INSTALL_FULL_LIBDIR}
PUBLIC_HEADER "mbelib.h")

configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libmbe.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/libmbe.pc"
@ONLY)

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libmbe.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")

install(TARGETS mbe-static mbe-shared
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

# uninstall target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)

add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)

option(DISABLE_TEST "Disable building of test framework." OFF)

if (NOT DISABLE_TEST)
enable_testing()
add_subdirectory(test)
endif()
14 changes: 14 additions & 0 deletions mbelib-wasm/mbelib/COPYRIGHT
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Copyright (C) 2010 mbelib Author
GPG Key ID: 0xEA5EFE2C (9E7A 5527 9CDC EBF7 BF1B D772 4F98 E863 EA5E FE2C)

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
28 changes: 28 additions & 0 deletions mbelib-wasm/mbelib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[![Build Status](https://travis-ci.org/szechyjs/mbelib.png?branch=master)](https://travis-ci.org/szechyjs/mbelib)

PATENT NOTICE

This source code is provided for educational purposes only. It is
a written description of how certain voice encoding/decoding
algorythims could be implemented. Executable objects compiled or
derived from this package may be covered by one or more patents.
Readers are strongly advised to check for any patent restrictions or
licencing requirements before compiling or using this source code.

mbelib 1.3.0

mbelib supports the 7200x4400 bit/s codec used in P25 Phase 1,
the 7100x4400 bit/s codec used in ProVoice and the "Half Rate"
3600x2250 bit/s vocoder used in various radio systems.

Example building instructions on Ubuntu:

sudo apt-get update
sudo apt-get install git make cmake # Update packages
git clone <URL of git repository> # Something like: git@github.com:USERNAME/mbelib.git
cd mbelib # Move into source folder
mkdir build # Create build directory
cd build # Move to build directory
cmake .. # Create Makefile for current system
make # Compiles the library
sudo make install # Library is installed into computer
Loading