Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major Refactoring #43

Merged
merged 31 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
d5635ee
Refactored Autocorrelation per Google C++ style
tornupnegatives Jul 6, 2023
1d8d5db
Merged headers and sources per Canonical Project Structure
tornupnegatives Jul 8, 2023
0288844
Refactored AudioBuffer
tornupnegatives Jul 18, 2023
b693f43
Refactored AudioFilter
tornupnegatives Jul 22, 2023
43636d8
Replaced AudioFilter source header with copyright
tornupnegatives Jul 22, 2023
c90b831
Removed trivial AudioFilter constructor
tornupnegatives Jul 22, 2023
8995dbf
Refactored BitstreamGenerator
tornupnegatives Jul 22, 2023
460d7f0
Refactored PathUtils
tornupnegatives Jul 22, 2023
e37309e
Refactored Frame
tornupnegatives Jul 23, 2023
c310fa9
Refactored FrameEncoder
tornupnegatives Jul 23, 2023
fe21a2d
Refactored FramePostProcessor
tornupnegatives Jul 24, 2023
72669a3
Re-added casts
tornupnegatives Jul 24, 2023
a40200e
Refactored Synthesizer
tornupnegatives Jul 24, 2023
936c029
Refactored Tms5220CodingTable -> CodingTable
tornupnegatives Jul 24, 2023
2c8e2d4
Merge branch 'main' into cpplint
tornupnegatives Jul 24, 2023
4423405
Refactored Autocorrelation
tornupnegatives Jul 26, 2023
5d4a9bd
Refactored LinearPredictor
tornupnegatives Jul 26, 2023
d46c184
Refactored Pitch Estimator
tornupnegatives Jul 30, 2023
83f7f2b
Refactored AudioWaveform
tornupnegatives Aug 5, 2023
10a0d5d
Refactored AudioWaveformView
tornupnegatives Aug 6, 2023
1df949f
Documented members
tornupnegatives Aug 6, 2023
8e5a492
Re-factored Control Panel View
tornupnegatives Aug 6, 2023
5960ea8
Re-factored Control Panel Post View
tornupnegatives Aug 6, 2023
4edb62f
Re-factored Control Panel Pitch View
tornupnegatives Aug 6, 2023
b31144b
Re-factored Control Panel LPC View
tornupnegatives Aug 6, 2023
3229afd
Refactored Command Line App
tornupnegatives Aug 7, 2023
e2fcf75
Re-factored Main Window
tornupnegatives Aug 7, 2023
11bdd58
Re-factored tests
tornupnegatives Aug 7, 2023
66b4387
Re-factored CMakeLists
tornupnegatives Aug 7, 2023
360cc55
Re-factored README
tornupnegatives Aug 7, 2023
bb2f180
Added comment block after multi-line function declaration
tornupnegatives Aug 7, 2023
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ build/
.DS_Store

# IDEs
.cache/
.idea/
.vscode/
*.user
Expand Down
120 changes: 59 additions & 61 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,97 +1,95 @@
# Author: Joseph Bellahcen <joeclb@icloud.com>
# Copyright (C) 2023 Joseph Bellahcen <joeclb@icloud.com>

###############################################################################
# CMake Configuration #########################################################
###############################################################################

cmake_minimum_required(VERSION 3.14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Run Qt's moc, rcc, and uic tools
# Required for Qt
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

###############################################################################
# Project Configuration #######################################################
###############################################################################

project(TMS-Express)
option(TMSEXPRESS_BUILD_TESTS "Build test programs" ON)

# ====================================
# PROGRAM FILES
# ====================================
###############################################################################
# Project Sources & Includes ##################################################
###############################################################################

include_directories(
inc
lib
${CMAKE_CURRENT_LIST_DIR}
tms_express
)

add_executable(${PROJECT_NAME}
# ====================================
# BACKEND SOURCES
# ====================================
src/Audio/AudioBuffer.cpp
src/Audio/AudioFilter.cpp

src/LPC_Analysis/Autocorrelator.cpp
src/LPC_Analysis/PitchEstimator.cpp
src/LPC_Analysis/LinearPredictor.cpp

src/Frame_Encoding/Frame.cpp
src/Frame_Encoding/FrameEncoder.cpp
src/Frame_Encoding/FramePostprocessor.cpp
src/Frame_Encoding/Synthesizer.cpp

src/Bitstream_Generation/BitstreamGenerator.cpp
src/Bitstream_Generation/PathUtils.cpp
# Backend #################################################################
tms_express/Audio/AudioBuffer.cpp
tms_express/Audio/AudioFilter.cpp

# ====================================
# FRONTEND SOURCES
# ====================================
src/User_Interfaces/CommandLineApp.cpp
tms_express/LPC_Analysis/Autocorrelation.cpp
tms_express/LPC_Analysis/PitchEstimator.cpp
tms_express/LPC_Analysis/LinearPredictor.cpp

inc/User_Interfaces/MainWindow.h
src/User_Interfaces/MainWindow.cpp
tms_express/Frame_Encoding/Frame.cpp
tms_express/Frame_Encoding/FrameEncoder.cpp
tms_express/Frame_Encoding/FramePostprocessor.cpp
tms_express/Frame_Encoding/Synthesizer.cpp

inc/User_Interfaces/Audio_Waveform/AudioWaveform.h
src/User_Interfaces/Audio_Waveform/AudioWaveform.cpp
tms_express/Bitstream_Generation/BitstreamGenerator.cpp
tms_express/Bitstream_Generation/PathUtils.cpp

inc/User_Interfaces/Audio_Waveform/AudioWaveformView.h
src/User_Interfaces/Audio_Waveform/AudioWaveformView.cpp
# Frontend ###############################################################
tms_express/User_Interfaces/CommandLineApp.cpp

inc/User_Interfaces/Control_Panels/ControlPanelView.h
src/User_Interfaces/Control_Panels/ControlPanelView.cpp
tms_express/User_Interfaces/Audio_Waveform/AudioWaveform.cpp
tms_express/User_Interfaces/Audio_Waveform/AudioWaveformView.cpp

inc/User_Interfaces/Control_Panels/ControlPanelPitchView.h
src/User_Interfaces/Control_Panels/ControlPanelPitchView.cpp
tms_express/User_Interfaces/Control_Panels/ControlPanelView.cpp
tms_express/User_Interfaces/Control_Panels/ControlPanelPitchView.cpp
tms_express/User_Interfaces/Control_Panels/ControlPanelLpcView.cpp
tms_express/User_Interfaces/Control_Panels/ControlPanelPostView.cpp

inc/User_Interfaces/Control_Panels/ControlPanelLpcView.h
src/User_Interfaces/Control_Panels/ControlPanelLpcView.cpp
tms_express/User_Interfaces/MainWindow.cpp

inc/User_Interfaces/Control_Panels/ControlPanelPostView.h
src/User_Interfaces/Control_Panels/ControlPanelPostView.cpp

src/main.cpp
)
# Main ####################################################################
tms_express/main.cpp
)

# ====================================
# DYNAMIC LIBS
# ====================================
find_package(Qt6 COMPONENTS Core Gui Multimedia Widgets PrintSupport REQUIRED)
###############################################################################
# Project Dependencies ########################################################
###############################################################################

find_package(Qt6 COMPONENTS Core Gui Multimedia Widgets REQUIRED)
find_package(PkgConfig REQUIRED)

pkg_check_modules(SndFile REQUIRED IMPORTED_TARGET sndfile)
pkg_check_modules(SampleRate REQUIRED IMPORTED_TARGET samplerate)

target_link_libraries(${PROJECT_NAME}
PRIVATE
PkgConfig::SndFile
PkgConfig::SampleRate
Qt::Core
Qt::Gui
Qt::Widgets
Qt::PrintSupport
Qt::Multimedia
)

# Rename executable
PRIVATE
PkgConfig::SndFile
PkgConfig::SampleRate
Qt::Core
Qt::Gui
Qt::Widgets
Qt::Multimedia
)

###############################################################################
# Artifacts & Sub-Targets #####################################################
###############################################################################

set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME tmsexpress)

if (TMSEXPRESS_BUILD_TESTS)
message(STATUS "Building TMS Express test suite")
include(test/TmsTest.cmake)
add_subdirectory(test)
endif()
63 changes: 44 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ TMS Express generates bitstreams for the TMS5220 Voice Synthesis Processor.

![TMS Express GUI Screenshot](doc/screenshot.png)

The TMS5220 hardware and its software analogues (i.e. Arduino Talkie) alike may be driven by the output of TMS Express.
The program accepts audio files in a variety of formats, applies linear predictive coding (LPC) to compress the data,
The TMS5220 hardware and its software analogues (i.e. Arduino Talkie) alike may
be driven by the output of TMS Express. The program accepts audio files in a
variety of formats, applies linear predictive coding (LPC) to compress the data,
and outputs either an ASCII bitstream or C header with the encoded data.

Compared to existing encoders, TMS Express has the following advantages:
- Implements the original Levinson-Durbin recursion to determine LPC coefficients
- Implements the original Levinson-Durbin recursion to determine LPC
coefficients
- Supports repeat frames for enhanced audio compression
- Automatically downsamples and mixes audio files of any format
- Performs batch encoding of multiple files
Expand Down Expand Up @@ -39,33 +41,56 @@ $ cmake --build . -j

## Usage
## GUI
To launch the TMS Express GUI frontend, simply invoke the program with no arguments
To launch the TMS Express GUI frontend, simply invoke the program with no
arguments

```shell
$ tmsexpress
```

## The Encode Command
The `encode` command accepts audio file(s) and a variety of parameters which affect how they are processed, analyzed,
and formatted for output. TMS Express automatically detects when the input path is a directory and performs a batch job.
The `encode` command accepts audio file(s) and a variety of parameters which
affect how they are processed, analyzed, and formatted for output. TMS Express
automatically detects when the input path is a directory and performs a batch
job.

```shell
$ tmsexpress encode [OPTIONS] input output
```

### Explanation of Options
- `window`: Speech data is separated into small windows/segments, each of which are analyzed individually. This is because small enough segments of speech data are roughly periodic and their behavior may be generalized. An ideal window width is between 22.5-25 ms
- Values above and below the recommendation will artificially speed up and slow down speech, respectively
- `highpass` and `lowpass`: Speech data occupies a relatively small frequency band compared to what digital audio files are capable of representing. Filtering out unnecessary frequencies may lead to more accurate LPC analysis
- Lowering the highpass filter cutoff will improve the bass response of the audio
- `window`: Speech data is separated into small windows/segments, each of which
are analyzed individually. This is because small enough segments of speech
data are roughly periodic and their behavior may be generalized. An ideal
window width is between 22.5-25 ms
- Values above and below the recommendation will artificially speed up and
slow down speech, respectively
- `highpass` and `lowpass`: Speech data occupies a relatively small frequency
band compared to what digital audio files are capable of representing.
Filtering out unnecessary frequencies may lead to more accurate LPC analysis
- Lowering the highpass filter cutoff will improve the bass response of the
audio
- Adjusting the lowpass cutoff may have minor effects of pitch estimation
- `alpha`: While the pitch of speech is characterized by the lower frequency band, LPC algorithms which characterize the upper vocal tract benefit from an exaggeration of high frequency data. A pre-emphasis filter will exaggerate this part of the spectrum and lead to crisper, more accurate synthesis
- `format`: ASCII format is ideal for testing and visualization of single files. The C and Arduino format produce C headers for use with TMS5220 emulations
- `no-stop-frame`: An explicit stop frame signals to the TMS5220 that the Speak External command has finished executing
- `gain`: Increases the gain of the synthesized signal by adjusting the index of the coding table element. Gain offsets greater than the max size of the coding table will hit the ceiling
- `max-voiced-gain`: Specifies the maximum gain (dB) of the output signal for voiced frames (vowels)
- `max-unvoiced-gain`: Specifies the maximum gain (dB) of the output signal for unvoiced frames (consonants)
- Ensuring that this value hovers around `0.8 * max-voiced-gain` will result in the most accurate synthesis of consonant sounds
- `alpha`: While the pitch of speech is characterized by the lower frequency
band, LPC algorithms which characterize the upper vocal tract benefit from an
exaggeration of high frequency data. A pre-emphasis filter will exaggerate
this part of the spectrum and lead to crisper, more accurate synthesis
- `format`: ASCII format is ideal for testing and visualization of single
files. The C and Arduino format produce C headers for use with TMS5220
emulations
- `no-stop-frame`: An explicit stop frame signals to the TMS5220 that the
Speak External command has finished executing
- `gain`: Increases the gain of the synthesized signal by adjusting the index
of the coding table element. Gain offsets greater than the max size of the
coding table will hit the ceiling
- `max-voiced-gain`: Specifies the maximum gain (dB) of the output signal for
voiced frames (vowels)
- `max-unvoiced-gain`: Specifies the maximum gain (dB) of the output signal for
unvoiced frames (consonants)
- Ensuring that this value hovers around `0.8 * max-voiced-gain` will result
in the most accurate synthesis of consonant sounds
- `use-repeat-frames`: Detect repeat frames to reduce the size of the bitstream
- `max-frq`: Specifies the maximum representable pitch frequency of the output signal
- `min-frq`: Specifies the minimum representable pitch frequency of the output signal
- `max-frq`: Specifies the maximum representable pitch frequency of the output
signal
- `min-frq`: Specifies the minimum representable pitch frequency of the output
signal
46 changes: 0 additions & 46 deletions inc/Audio/AudioBuffer.h

This file was deleted.

29 changes: 0 additions & 29 deletions inc/Audio/AudioFilter.h

This file was deleted.

38 changes: 0 additions & 38 deletions inc/Bitstream_Generation/BitstreamGenerator.h

This file was deleted.

Loading