VBA-M Forums

Full Version: A sound test program which fails
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This is a program that plays stuff through the sound channels, then uses the GBA timers to calculate exact times for the waveform to be okay before starting a new sound at a lower volume.
It sounds significantly different on hardware compared to VBA-M.
The sound played is just repeating E notes, but it waits for the exact timing necessary to begin another note with no impact from the "reset" bit.
On hardware it sounds smooth. On VBA-M, it sounds clicky/noisy/metalic.

Code:
//get_wavelength(4);
void test2()
{
    REG_IME=0;
    
    REG_TM2CNT_H=0;
    REG_TM2CNT_L=0;
    REG_TM2CNT_H=0xC1;   //256KiHz timer
    
    REG_SOUNDCNT_X=0x80;
    REG_SOUNDCNT_L=0xFF77;
    
    int period = 0x673; //E-note after middle C
    int target_time;
    int last_time=0;
    int num_tones=6;
    int volume=15;
    int real_period=2048-period;
    
    do
    {
        target_time=last_time+real_period*2*num_tones;
        target_time&=0xFFFF;
        while (1)
        {
            if (REG_TM2CNT_L==target_time-1)
            {
                break;
            }
        }
        REG_SOUND1CNT_H = 0x80 + (volume<<12);
        REG_SOUND1CNT_X = 0x8000 + period;
        last_time=target_time;
        volume--;
        if (volume==0) volume=15;
    } while (1);
}
Thanks.

Any chance of a recording of the original sound and how VBA-M sounds?
ah, so where would the fault lie.... the sound core, or the output itself...
This is in the sound core.
Sorry about some misinformation, it is not completely smooth on a GBA.

The wave is normally ~134 samples wide.
There is a 'bad wave' which is ~26 samples longer every ~1468 samples on VBA-M. The bad wave sounds like a pop. You get a pop about ~30 times a second.
The bad wave (~26 samples longer) occurs every ~5638 samples on hardware, so it's less noticable. The pop appears ~7.8 times a second.

I've attached the test program, VBA-M's wav output, and a bad recording of what hardware produces. WAV files don't compress well, so it's 900k.[attachment=23]
ah, ok, well i've been having somewhat a feeling that the gba sound core wasn't correct.. i've noticed some strange squeaking at certain points in a few games, i just thought it was my single core cpu....
Well, in that case, please let us know squall so Nach, Jonas, Spacy or I can have a look at them.
it was most noticeble in Super Robot Taisen - Original Generation 1 and 2
I've been noticing this white noise when playing GBA games, its only audible when you come to a point where no bgm or sound is playing, and it sounds a wave thats eternally moving in, but not going back out.

Its not audible in DMG or CGB games.

related at all Dwedit?

a better description would be scratching to pieces of metal together, albeit very slowly,
Here's a more or less clean recording from my NDS using my new ASUS Xonar DX sound card ^^
(NDS headphone jack to sound card line in, 48 kHz recording)
This will likely be fixed when Blargg rewrites the audio core.
Reference URL's