Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Philips Semiconductors TDA8425 Hi-fi stereo audio processor emulation library

License

NotificationsYou must be signed in to change notification settings

TexZK/TDA8425_emu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This library aims to emulate thePhilips Semiconductors TDA8425 Hi-fi stereo audio processor.

Block diagram

The original goal is to contribute to the emulation of theAdLib Gold soundcard, which used such integrated circuit to add sound effects to the audiooutput, as heard in the beautiful soundtrack of theDune videogame, madespecifically for that rare sound card.

As I do not know how the actual circuits are made, I cannot emulate the chipperfectly. Instead, my goal is to simulate the overall sound, based on theshort information available.

If anybody can analyze a decapped chip, that would of course be the bestinformation, as already done for many vintage sound chips.

I am willing to get some real chips, as long as they are available forpurchase, at least for black-box comparisons with dedicated test vectors.


Usage

To use this library, just includeTDA8425_emu.c andTDA8425_emu.hinto your project.

The engine implements the following conceptual flow:

  1. TDA8425_Chip memory allocation.
  2. CallTDA8425_Chip_Ctor() to invalidate internal data.
  3. CallTDA8425_Chip_Setup() to initialize static settings.
  4. CallTDA8425_Chip_Reset() to clear emulated registers.
  5. CallTDA8425_Chip_Write() for each register to inizialize.
  6. CallTDA8425_Chip_Start() to start the algorithms.
  7. Processing loop:
    1. CallTDA8425_Chip_Process() for each sample, with appropriate datatypes.
  8. CallTDA8425_Chip_Stop() to stop the algorithms.
  9. CallTDA8425_Chip_Dtor() to deallocate and invalidate internal data.
  10. TDA8425_Chip memory deallocation.

Register access timings are not emulated.

You can give a look at theTDA8425_pipe example formore details.


Implementation details

Here you can find some descriptions and discussions about implementationdetails.

Language

I choseC99, because I find good old and mature C to be the best for such atiny library. C is also easier to integrate with other languages.

Cross-platform support

The code itself should be cross-platform and clean enough not to givecompilation errors or ambiguity.

Currently the library is developed and tested underWindows withMSVC++14.Of course, I will at least provide support forgcc andclang underLinux.I do not have access tomacOS, but I guess theLinux support should fit.

Code style

I chose the path of verbosity for variable declaration, to help debugging fixedpoint math and buffering. Indeed, when compiled for performance, all thosevariable declarations get optimized away easily.

Floating-point

It is possible to configure the floating point data type used for processing,via theTDA8425_FLOAT preprocessor symbol. It defaults todouble(double precision).

Please note that, contrary to common beliefs, thedouble data type isactually very fast on machines with hardware support for it.

I think that you should switch tofloat (single precision) only if:

  • the hardware is limited to it, or
  • if machine code vectorization gets faster, or
  • conversion from/to buffer data to/from double precision is slower.

Input selector

The input selector simply chooses which channels to feed to the internalprocessing units.

TheTDA8425_Chip_Process() method is always provided with two stereo sources.

DC removal

The library can optionally apply a high-pass filter at 10 Hz to the inputs, inorder to emulate the DC removal shown in the frequency response charts.


Stereo modes

Forced mono

Theforced mono mode simply adds the two input channels together, duplicatingthe summed signal.

It looks like there is an error in the datasheet, where a switch on the rightchannel is flipped, leading to some weird path, while it is clear that it wouldsimply feed the opamp with the sum of the two channels, just like for the leftchannel:

Forced mono errata corrige

Linear stereo

Thelinear stereo mode does not alter the two input channels.

Pseudo stereo

Thepseudo stereo mode applies two cascaded all-pass filters to the leftchannel.

All-pass filters can be configured by changing the external capacitance, as peran actual chip. The library provides the three preset values mentioned in thedatasheet.

The datasheet describes the pseudo stereo with a clear schematic.By knowning the phase diagram and the associated capacitance values, it ispossible to calculate the internal resistance values.The scriptTDA8425_pseudo.py was used in thedevelopment, to expand the expressions to calculate the biquad coefficients.It also helped in the identification of internal resistance values, whichshould be around 15 kΩ, but it looks like the plots on the datasheet are not asaccurate as those of the script.

The filter as a whole is implemented as abiquad filter.

Pseudo stereo schematic highlight

Pseudo stereo phase diagram

Spatial stereo

Thespatial stereo simply adds some cross-talk between the channels.

The relationship between generic channelsa andb is the following:

Voa(t) = Via(t) + Rfa/Rc * (Via(t) - Vib(t))

whereRfa/Rc is 52%.

A simple ideal circuit is emulated in theSPICE model:TDA8425_spatial.asc.

Spatial stereo schematic highlight


Tone control

The datasheet plots the frequency response diagrams of two filters: thespecified one, and the mysterious (at least for me)T-filter.

Thespecified filter is a classic Baxandall-like tone control, with singlepole/zero shelving filters for both bass and treble controls.It looks like the they are centered around 300 Hz and 4500 Hz, respectively.I chosebi-linear implementation instead ofbi-quadratic for both filters,to maintain separation of concerns.They were designed with the help of theTDA8425_shelving.py Python script.

Furthermore, it looks like theT-filter has an additional second-orderfrequency response for bass control, which is factored into a dedicated biquadfilter. You can refer to theTDA8425_tfilter.py Python script for reference.

Tone control "specified" frequency response

Tone control "T-filter" frequency response


TDA8425_pipe example

This repository provides a fully-featured example. It is a stream processor, inthat it processes sample data coming fromstandard input, elaborates it, andgenerates outputs on thestandard output.

Please refer to its own help page, by calling the canonicalTDA8425_pipe --help, or reading it embedded inits source code.

Usage example with Lubuntu 20.04

  1. Ensure the following packages are installed:
sudo apt install alsa-utils audacity build-essential python3
  1. Enterexample folder and runmake_gcc.sh:
cd examplebash make_gcc.sh
  1. You should find the generated executable file asTDA8425_pipe.

  2. Generate some noise at 192000 Hz, stereo, signed 16-bit little-endian:

python3 gen_noise.py
  1. You should find the generated noise sample asnoise.raw.

  2. Process noise to have full bass and treble boost, withT-filter:

./TDA8425_pipe -r 192000 -c 2 -f S16_LE -v -6 -b +15 -t +12 --t-filter< noise.raw> out.raw
  1. Importout.raw asraw data withAudacity:

Import raw data

  1. Plot the spectrum analysis:

Full boost spectrum analysis

  1. You can also play the audio directly withaplay (the\ is for commandline continuation):
./TDA8425_pipe -r 192000 -c 2 -f S16_LE -v -6 -b +15 -t +12 --t-filter< noise.raw \| aplay -c 2 -r 192000 -f S16_LE

[8]ページ先頭

©2009-2025 Movatter.jp