NESDev and Strangulation Records messageboards
Forum Index | FAQ | New User | Login | Search

Previous ThreadView All ThreadsNext Thread*Show in Threaded Mode


SubjectLogarithmic conversions... new  
Posted byAnonymous
Posted on5/21/03 1:12 PM
From IP65.41.175.152  



This is a somewhat unrelated question to NES emulation, and I will likely ask it wrong...I am not all that great with "sound" issues.


What are db equivelants to the 16 different steps of Amplitude of the pAPU (if 0 db = 0x0F (full sound).......and ........-100 db = 0 (silence)? How do I calculate (or what are) reasonable db values (I don't know how to convert Logarithmic db values to a "linear" representation of these 16 steps....

So if I was to build a chart, I have.....

0x0F ------------- 0 db (highest Vollume)
0x0E
0x0D
...
...
0x01
0x00 ------------- -100 db (No sound heard)

Obviously I can't devide the steps into Equal (100/16 different vollume steps) parts becuase db do not operate on a linear scale....In fact silence will come long before -100 db is reached...

So if if the APU wants to Fade the sound, I can (through directsound) fade the current Amplitude by setting the new Vollume. The only problem is the Vollume is set in Decibals (0 -> -100 db). I don't know how to convert the Vollume steps to db to get a nice "smooth" fade. I'm guessing at the values now, but I'd like some accurate numbers....Anybody know how to figure them out?


Thanks again







SubjectRe: Logarithmic conversions... new  
Posted byquietust
Posted on5/21/03 7:25 PM
From IP204.95.217.2  



I would not recommend using DirectSound to control sound channel amplitudes, mainly because it would require a buffer for each sound channel you wish to emulate (5 sound channels, plus any additional ones you might get from certain mappers).
A better approach would probably be the way most people already do it: generate each sound wave for each channel (at their respective amplitudes) and mix them together into a single waveform, then send *that* waveform to DirectSound (at maximum volume, of course).
The main advantage is that you only have to deal with buffering for one sound channel; the disadvantage is that you have to manually generate each channel's waveform in real-time (but you should be doing this already).

The proper way to do fades is to let the APU do them for you. Read Brad Taylor's APU document (which you should have done already) to figure out how the envelope generator works - take the bits written to the channel volume, add 1 (to get N), then decrement the channel amplitude once every N quarter-frames.

--
Quietust
P.S. If you don't get this note, let me know and I'll write you another.


SubjectRe: Logarithmic conversions... new  
Posted byAnonymous
Posted on5/21/03 8:13 PM
From IP65.41.175.152  



Thanks for the response...I am generating the waveforms separatly, and letting Directsound mix them/fade them. I have to use a separate buffer for each...I didn't realize that was a poor way of doing it...I'm new to sound emulation...

I'd love to figure out how to mix the buffers myself. How do you do that? If I have a:

unsigned char sq1Buffer[4_FramesWorth];
unsigned char sq2Buffer[4_FramesWorth];

How do I generate a third buffer that is the euqivalent of these 2? I'm not sure on the algorithm of mixing two waveforms together.....Is it just a buffer that contains every byte of the initial 2 buffers but alternating likie this:

byte0_sq1....byte0_sq2.....byte1_sq1....byte1_sq2...etc....?

I also do not understand how your method works. The pAPU will fade the Amplitude when it wants to (I'm following Brad Taylor's docs), but the updates would not be dynamic (as far as what you hear), becuause I'm only generating waveform data once per frame (an emulation issue).

So everytime an update is made to the amplitude of my "combined" sound wave buffer (up to 240 times per second)....I'll have to stop, and do a linear scan/update of every value in the combined array to reflect the new change in vollume?

Is this what you mean? I'm not following exactly, becuase without this step, the only "audible" difference would be heard every 1/60th of a frame (which is how often I even generate waveforms based on the current Amplitude)....

Letting directsound fade it was the only way I could figure to get an "immediate" audible result (without having to scan/change all the values of my current sound buffers upto 240 timers per second)

I know much of this is about my current emulation design..Any advice?










SubjectRe: Logarithmic conversions...  
Posted byMemblers
Posted on5/22/03 01:46 AM
From IP68.58.99.218  



I've been learning about sample mixing recently, I can offer some basic ideas.

Mixing samples is simply adding them together (samples need to be in signed format, I believe). Just be sure that the result can't ever go past the maximum amplitude (consider the worst-case-scenario, all channels at full volume).




Previous ThreadView All ThreadsNext Thread*Show in Threaded Mode
Jump to

Memblers' homepage             Contact Me

Forums powered by WWWThreads Demo