VOGONS


First post, by superfury

User metadata
Rank l33t++
Rank
l33t++

When I try to make UniPCemu record audio using it's Sound Blaster emulation, which I've modified a little bit to allow real-time recording as well as inputting a test signal(1Hz sine wave) for testing, somehow the audio ends up being a lot of noise instead of the intended wave. Is it correct, that the input signal using the Sound Blaster 2.0 is just a simple unsigned 8-bit signal? (0=-5V, 128=0V, 255=+5V)

It currently generates a 16-bit PCM stream for recording, like the actual recording in the OS does(SDL2 recording input).

						#ifdef RECORD_TESTWAVE
sample = (sword)(sinf(2.0f*PI*1.0f*recordtime)*(SHRT_MAX/2.0)); //Use a test wave instead!
recordtime += (1.0f/SOUNDBLASTER.frequency); //Tick time by one sample!
recordtime = fmodf(recordtime,1.0f); //Wrap around a second!
SOUNDBLASTER.recordedsample = ((signed2unsigned16(sample)>>8)^0x80); //Test sample to use!
#else
SOUNDBLASTER.recordedsample = (byte)(((word)getRecordedSampleL8u()+(word)getRecordedSampleR8u())*0.5f); //Update recording samples in real-time, mono!
#endif

The signed2unsigned and unsigned2signed function just convert between (un)signed variants of the same variable by putting it in a union and reading the (un)signed version from the other variable. That way, signed vs unsigned conversions are easily handled without chance of data being modified by compiler logic in ways that are unintended(assuming signed vs unsigned have the same size). So unsigned 32768 is signed -32768 when converted that way.

I'm using the record.exe from the Sound Blaster 1.5 driver disks at http://www.vogonsdrivers.com/index.php?catid= … menustate=42,35

Resulting recording of the Sound Blaster recording a 1Hz wave:

Filename
TEST4.zip
File size
6.1 KiB
Downloads
39 downloads
File comment
Test recording of a simple 1Hz sine wave using the record program of the SoundBlaster 2.0 disks from vogonslibary.
File license
Fair use/fair dealing exception

Anyone can see what's going wrong in the emulation?

Sound Blaster source code(RECORD_TESTWAVE makes it generate a 1Hz test wave on the recording input instead of the actual recording from the SDL input):
https://bitbucket.org/superfury/unipcemu/src/ … ter.c?at=master

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io