Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

Tyrian 2000 in DOS with sound on PCIe only machines? (Announce)

posted by Japheth Homepage, Germany (South), 28.03.2024, 06:10

> I understand that for adding 2 signals together the sample value need to be
> halved before to avoid overflow/clipping the result

It's not "halved", it's using kind of a "geometric mean", looks rather complicated ( because the sample values are "signed"):


for( i = 0; i < samples * 2; i++ ) {
   int a = (*(pPCM+i) * (int)voicevol / 256) + 32768;    /* convert to 0-65535 */
   int b = (*(pOPLPCM+i) * (int)midivol / 256 ) + 32768; /* convert to 0-65535 */
   int mixed = (a < 32768 || b < 32768) ? ((a*b)/32768) : ((a+b)*2 - (a*b)/32768 - 65536);
   *(pPCM+i) = (mixed > 65535 ) ? 0x7fff : mixed - 32768;
}


IIRC crazii found this somewhere on "stackoverflow". I will happily adjust vsbhda if you know something better.

---
MS-DOS forever!

 

Complete thread:

Back to the forum
Board view  Mix view
22049 Postings in 2034 Threads, 396 registered users, 253 users online (0 registered, 253 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum