Unify LPC coefficient tables with architectural improvements#9
Merged
Unify LPC coefficient tables with architectural improvements#9
Conversation
Refactors the codebase to use tmsTables.ts as the single source of truth
for TMS5220/TMS5100/TMS5200 speech synthesis coefficient tables, eliminating
duplicate table definitions and improving maintainability.
## Key Changes
### Architecture Improvements
- Added `ChipVariant` type for type-safe chip selection ('tms5220' | 'tms5100' | 'tms5200')
- Added `CodingTable.getChipConfig()` for controlled table access
- Added `CodingTable.getSynthesisK()` for proper coefficient quantization
- All chip variants now fully supported (including tms5200)
### Table Unification
- Removed ~120 lines of duplicate hardcoded tables from talkieStream.ts
- TalkieStream now uses tmsTables.ts for all coefficient data
- Phrase definitions updated to use lowercase chip identifiers
- Net reduction: 72 lines of code (-155/+83)
### Critical Fix: Synthesis Quantization
- Encoding uses normalized coefficient values from tmsTables
- Synthesis requires quantized fixed-point register values
- Added conversion logic in CodingTable.getSynthesisK():
- K1/K2: multiply by 64 (16-bit signed Q15 format)
- K3-K10: divide by 4 (8-bit signed Q7 format)
- TalkieStream initializes separate synthesis lookup tables on say()
### API Changes
- TalkieStream.say() now accepts ChipVariant string instead of number
- Removed backward compatibility constants (TalkieDevice.*)
- LpcEncoder/LpcPlayer components use ChipVariant type throughout
## Benefits
- Single source of truth for coefficient tables
- Type-safe chip variant selection
- Proper separation of encoding vs synthesis representations
- Smaller bundle size (~400 bytes saved)
- Support for all TMS chip variants
- Improved maintainability and testability
## Testing
- All 28 unit tests passing ✓
- Build and lint checks passing ✓
- Playback functionality verified for all chip variants ✓
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Deploying ch32v003-music with
|
| Latest commit: |
06685f0
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://b2d846cd.ch32v003-music.pages.dev |
| Branch Preview URL: | https://refactor-unified-tables.ch32v003-music.pages.dev |
Run Prettier to fix formatting issues in 10 files. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactors the codebase to use
tmsTables.tsas the single source of truth for TMS5220/TMS5100/TMS5200 speech synthesis coefficient tables, eliminating duplicate table definitions and improving maintainability.Key Changes
Architecture Improvements
ChipVarianttype for type-safe chip selection ('tms5220' | 'tms5100' | 'tms5200')CodingTable.getChipConfig()for controlled table accessCodingTable.getSynthesisK()for proper coefficient quantizationTable Unification
talkieStream.tstmsTables.tsfor all coefficient dataCritical Fix: Synthesis Quantization
CodingTable.getSynthesisK():say()API Changes
TalkieStream.say()now acceptsChipVariantstring instead of numberTalkieDevice.*)ChipVarianttype throughoutBenefits
Testing
Files Changed
src/tmsTables.ts- AddedChipVarianttype andCodingTablestatic methodssrc/talkieStream.ts- Major refactor, removed ~120 lines of duplicate tablessrc/lib/tools/LpcEncoder.svelte- Updated to useChipVarianttypesrc/lib/tools/LpcPlayer.svelte- Updated to useChipVarianttypesrc/lpc-phrases/*.ts(5 files) - Updated table identifiers to lowercase🤖 Generated with Claude Code