10/31/2023: Localization News - Dead of the Brain 1!

No, NOT a trick, a Halloween treat! Presenting the Dead of the Brain 1 English patch by David Shadoff for the DEAD last official PC Engine CD game published by NEC before exiting the console biz in 1999! I helped edit/betatest and it's also a game I actually finished in 2023, yaaay! Shubibiman also did a French localization. github.com/dshadoff/DeadoftheBrain
twitter.com/NightWolve/PCENews
Main Menu

White Noise not Working?

Started by Lochlan, 07/19/2013, 08:49 AM

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Lochlan

Recently I've been playing around with the sound hardware (under emulation).  For some reason I can't get white noise to work in my huc project.  I'm calling this function on a button press:

whitenoise() {
#asm
lda     #4              ; Select channel 4
sta     $800
lda     #%000_11111     ; Stop playing waveform
sta     $804            ; and set volume to $1F
lda     #$FF            ; Balance settings
sta     $805
lda     #$80+2          ; Noise ON and set frequency
sta     $807
#endasm
}

...but nothing is happening.  I ripped this directly from the huc documentation (doc/pce/psg.txt) so I don't understand why this isn't working.  I've used the button to do other things in other contexts, so I know that the function call should be fine.  I've tried playing with various values in the lower 5 bits written to $807 but nothing seems to be working.  I'm running my .pce ROM in Mednafen (after having various issues with Magic Engine).

What is going on here?  Does anybody have an idea?  Any advice is greatly appreciated.
Quote from: ridgewood_general_store_1 on 08/15/2014, 11:12 AMI'm not sorry about this, as I'm not sorry about ANY attack by the goverrats.

OldRover

I dunno what else you have in your code, but that doesn't look sufficient on its own. Without testing it myself, I can only think of the following addition:

    lda    #$FF
    sta    $801

at the end of your sound code. Also, I do believe that you have to put *something* in $807 ("note" data) on each frame.
Turbo Badass Rank: Janne (6 of 12 clears)
Conquered so far: Sinistron, Violent Soldier, Tatsujin, Super Raiden, Shape Shifter, Rayxanber II

touko

#2
$804 value is $9F if you want to set voice on, and volume at his maximum(ie #31 or #$1F ) .
Of course for psg mode, not for DDA output .

bit 7 must be 1(voice ON) and bits 0->4 is for voices volume setting

Also for noice frequencies, their range is #$80 -> #$FF, and if you put a value, less than #$80, you will hear nothing..

OldMan

Quote$804 value is $9F if you want to set voice on, and volume at his maximum(ie #31 or #$1F ) .
Agreed. You turn the channel off at the start, but never turn it back on in white noise mode.
Also, do you load the waveform buffer? It is used to generate the white noise, I believe.
And finally, did you turn the main volume on? I often forget that one.....

Arkhan Asylum

This looks like a job for Squirrel!

:D

But yes, if you don't init the main volume and the channel volumes, it may be working.

Very quietly. 
This "max-level forum psycho" (:lol:) destroyed TWO PC Engine groups in rage: one by Aaron Lambert on Facebook "Because Chris 'Shadowland' Runyon!," then the other by Aaron Nanto "Because Le NightWolve!" Him and PCE Aarons don't have a good track record together... Both times he blamed the Aarons in a "Look-what-you-made-us-do?!" manner, never himself nor his deranged, destructive, toxic turbo troll gang!

touko

#5
Quote from: TheOldMan on 07/19/2013, 01:48 PMAlso, do you load the waveform buffer? It is used to generate the white noise, I believe.
And finally, did you turn the main volume on? I often forget that one.....
Yes i agree with that too ;-)
You don't need any waveform (it's auto generated) for this kind of sound .
And of course you should put the general volume ($801) at his max (#$FF) .

White noise is the easiest part on pce sound for me .

Arkhan Asylum

I thought there were EQUs for the addresses so you don't have to remember them.   If you use the EQUs its a bit easier to see what is going on, also.
This "max-level forum psycho" (:lol:) destroyed TWO PC Engine groups in rage: one by Aaron Lambert on Facebook "Because Chris 'Shadowland' Runyon!," then the other by Aaron Nanto "Because Le NightWolve!" Him and PCE Aarons don't have a good track record together... Both times he blamed the Aarons in a "Look-what-you-made-us-do?!" manner, never himself nor his deranged, destructive, toxic turbo troll gang!

Lochlan

Thanks for the help, guys.  As touko said, you don't need to set a waveform because the white noise generates a random waveform.

I needed to do two things to fix it:
1) Set bit 7 of $804 to re-enable the channel
2) Set the global volume on $801

Here is a working version of the code:

whitenoise() {
#asm
lda #4 ; Select channel 4
sta $800
lda #%000_11111 ; Stop playing waveform
sta $804 ; and set volume to $1F
lda #$FF ; Balance settings
sta $805
lda #%100_11111 ; Set bit 7 to turn the channel, set the volume to max
sta $804
lda #$FF ; Max volume both outputs
sta $801
lda #$80+2 ; Noise ON and set frequency
sta $807
#endasm
}

Quote from: guest on 07/19/2013, 03:04 PMI thought there were EQUs for the addresses so you don't have to remember them.   If you use the EQUs its a bit easier to see what is going on, also.
Those are in sndDefs.h (part of the sound libraries you guys seem to be using for all your code, including in Squirrel) which is not part of the default HuC libraries AFAIK.  Honestly I was just having a lot of trouble getting the compiled Squirrel .pces to work in Magic Engine (although they were fine in Mednafen) so I didn't want to rely on the sound libraries.
Quote from: ridgewood_general_store_1 on 08/15/2014, 11:12 AMI'm not sorry about this, as I'm not sorry about ANY attack by the goverrats.

OldMan

Glad to know its working now.

QuoteAs touko said, you don't need to set a waveform
kk. I thought the waveform was used as a sort of seed for the random noise. Though I don't know how you would tell any difference.

It's worth it to include sndDefs.h, just for readablility. I think the sound support in HuC is broken, or incomplete.
And we won't even get into using magic engine to test things....
Fwiw, we use mednafen and ootake to test things. If it works on both, it usually works on real hardware :)

Arkhan Asylum

Yeah, Magic Engine's audio likes to be special sometimes.

but, nothings stopping you from stealing those EQUs are redefining them yourself.   
This "max-level forum psycho" (:lol:) destroyed TWO PC Engine groups in rage: one by Aaron Lambert on Facebook "Because Chris 'Shadowland' Runyon!," then the other by Aaron Nanto "Because Le NightWolve!" Him and PCE Aarons don't have a good track record together... Both times he blamed the Aarons in a "Look-what-you-made-us-do?!" manner, never himself nor his deranged, destructive, toxic turbo troll gang!

touko

#10
@Lochlan: if you want to make music, use squirrel rather than huc sound driver, even if you want only make sfx, huc driver is not good at all,it will be better to make your own .

And if you want to mix the two, i think squirrel is also designed for, with arkhan and TheOldMan if you have any problem with it .

Arkhan Asylum

Yeah it does sound effects.  See: Pyramid Plunder

(or the Atlantean demo videos)
This "max-level forum psycho" (:lol:) destroyed TWO PC Engine groups in rage: one by Aaron Lambert on Facebook "Because Chris 'Shadowland' Runyon!," then the other by Aaron Nanto "Because Le NightWolve!" Him and PCE Aarons don't have a good track record together... Both times he blamed the Aarons in a "Look-what-you-made-us-do?!" manner, never himself nor his deranged, destructive, toxic turbo troll gang!