It is currently Sat Nov 17, 2018 11:09 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Stupid 5B questions
PostPosted: Sat Mar 24, 2018 8:55 pm 
Offline

Joined: Thu Aug 20, 2015 3:09 am
Posts: 414
Posting this in the music section instead of the emulator section in case any musicians have experimented with these edge cases.

Is volume zero audible? (I assume it isn't, but logarithmic scales never actually reach zero.)
What happens when you set the period registers to zero? (Is it the same as 1, does it wrap, or does it do something else entirely?)
What happens when you modify the period registers? (Does it affect the next period or the current one, I.E. does the chip count down or up?)
What happens when you modify the envelope shape while it's playing? (Probably the least-understood part of the chip, I'd be surprised if anyone actually knows the answer.)

The official docs I've scrounged don't mention any of the above, and the unofficial sources all seem to disagree on something. I've even found one YM2149 emulator that seems to flip-flop between treating noise period 0 as 1 or 32 depending on which VGM pack I feed it, with no obvious mechanism for it in the source! I'd be willing to write it off as a bug if fixing it didn't make one or the other of the two packs sound very weird.


Top
 Profile  
 
 Post subject: Re: Stupid 5B questions
PostPosted: Sat Mar 24, 2018 9:33 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 2333
Location: DIGDUG
I found a very nice datasheet for the YM2149.

http://www.atkinsoft.com/datasheets/YM2149.pdf

Volume zero looks pretty zero on their little graph.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
 Post subject: Re: Stupid 5B questions
PostPosted: Sun Mar 25, 2018 2:34 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 6956
Location: Canada
Rahsennor wrote:
Is volume zero audible? (I assume it isn't, but logarithmic scales never actually reach zero.)
What happens when you set the period registers to zero? (Is it the same as 1, does it wrap, or does it do something else entirely?)
What happens when you modify the period registers? (Does it affect the next period or the current one, I.E. does the chip count down or up?)
What happens when you modify the envelope shape while it's playing? (Probably the least-understood part of the chip, I'd be surprised if anyone actually knows the answer.)


There's no inconsistency with the logarithmic approach if you think "0-2 is 3db louder than 0-1, 0-3 is 3db louder than 0-2, etc." all of the steps between levels are on the logarithmic scale with each other, 0 is a reference baseline voltage, and 0-1 is a reference absolute step size, from which all the other logarithmic steps can be derived relatively. However, the logarithmic scale is only an ideal, I think the actual output isn't quite accurate to that PLUS I believe it's internal amplifier clips the high end of it down (on my to do list to measure this). Oh, and to answer the question, yes I believe volume 0 is silent (unless I'm remembering very badly).

Period 0 just halts the oscillator, if I recall. I don't have any precedent to expect a period of 1 to be the same as period 0 (is there some chip out there that does this?). Not sure why it would wrap, either, for the same reason.

The last two questions are getting into some really nitty details. At the same time as these two questions, I would ask what happens when you come out of period 0 (i.e. does period 0 work as an effective phase reset, or is it a true halt?). Asking "what happens if you --- while it's playing" is a pretty vague question though, there's more or less infinite permuations of things you could ask about this (does phase of envelope matter x number of possible phase steps, does phase of period matter x same, is there some other internal clock phase, etc. all of this x writing every bit of every control register) so all I can say at that point is...

If you've got a hotswap ROM test ready let me know and I can record it.


Top
 Profile  
 
 Post subject: Re: Stupid 5B questions
PostPosted: Sun Mar 25, 2018 5:27 am 
Offline

Joined: Thu Aug 20, 2015 3:09 am
Posts: 414
rainwarrior wrote:
Period 0 just halts the oscillator, if I recall. I don't have any precedent to expect a period of 1 to be the same as period 0 (is there some chip out there that does this?). Not sure why it would wrap, either, for the same reason.

I brought that up because MAME's emulator states period 0 behaves like period 1 for the noise and tone counters in the comments. According to them, the chip uses up counters that reset when they're greater than or equal to the period value, which does in fact give that behaviour, and has apparently been verified by register writes taking effect immediately instead of on the next period, prompting the third question. I'm sceptical that it would have been economical to implement the chip that way, and I don't have anything but this one file to back up this statement, so I'm taking it with a grain of salt.

Also, I have multiple VGM rips that actually use period zero, at least for (again) the noise channel, and seem to expect that it generates some sound. The fact that the pitch they seem to be expecting - and which even the one VGM player supplies - varies between different rips is what prompted the question. Some sound the same with 0 = 1, some with wrapping. I must be missing something, but I look at the write log, I see a zero, and I hear either a really deep sound or a really high one. I can't get them all to sound right with the same code. It's driving me up the wall.

rainwarrior wrote:
Asking "what happens if you --- while it's playing" is a pretty vague question though, there's more or less infinite permuations of things you could ask about this (does phase of envelope matter x number of possible phase steps, does phase of period matter x same, is there some other internal clock phase, etc. all of this x writing every bit of every control register) so all I can say at that point is...

That's why I was hoping to find a decap or something. There's a bunch of ways you could implement the envelope logic, and most of them will do different things if you start messing with parameters at different points. I doubt I could test every case even with hardware in front of me.

rainwarrior wrote:
If you've got a hotswap ROM test ready let me know and I can record it.

Do I have to do anything special for a hotswap? Will a simple NROM that loads itself into RAM and spams sprite DMA until a button is pressed do the trick? Is there any way I can test it in an emulator?


Top
 Profile  
 
 Post subject: Re: Stupid 5B questions
PostPosted: Sun Mar 25, 2018 8:20 am 
Offline
User avatar

Joined: Wed Feb 13, 2008 9:10 am
Posts: 664
Location: Estonia, Rapla city (50 and 60Hz compatible :P)
rainwarrior wrote:
Period 0 just halts the oscillator, if I recall. I don't have any precedent to expect a period of 1 to be the same as period 0 (is there some chip out there that does this?). Not sure why it would wrap, either, for the same reason.


On the TI PSG 0 produces lowest possible freq and 1 produces highest possible, and on SEGA VDP 0 is special cased to produce same output as 1. Those are not quite AY though lol.

Maximum attenuation on a channel does produce silence on a real AY (and the TI and VDP PSG). I haven't noticed any leakage effects.

_________________
http://www.tmeeco.eu


Top
 Profile  
 
 Post subject: Re: Stupid 5B questions
PostPosted: Sun Mar 25, 2018 11:39 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 6956
Location: Canada
Rahsennor wrote:
rainwarrior wrote:
Period 0 just halts the oscillator, if I recall. I don't have any precedent to expect a period of 1 to be the same as period 0 (is there some chip out there that does this?). Not sure why it would wrap, either, for the same reason.

I brought that up because MAME's emulator states period 0 behaves like period 1 for the noise and tone counters in the comments. According to them, the chip uses up counters that reset when they're greater than or equal to the period value, which does in fact give that behaviour, and has apparently been verified by register writes taking effect immediately instead of on the next period, prompting the third question. I'm sceptical that it would have been economical to implement the chip that way, and I don't have anything but this one file to back up this statement, so I'm taking it with a grain of salt.

Also, I have multiple VGM rips that actually use period zero, at least for (again) the noise channel, and seem to expect that it generates some sound. The fact that the pitch they seem to be expecting - and which even the one VGM player supplies - varies between different rips is what prompted the question. Some sound the same with 0 = 1, some with wrapping. I must be missing something, but I look at the write log, I see a zero, and I hear either a really deep sound or a really high one. I can't get them all to sound right with the same code. It's driving me up the wall.

Ah, that's interesting. I guess I could see that happening.

The old YM2149 emulator in NSFPlay appears to treat both period 0 and 1 as an "always on" silence. I couldn't say whether this is correct. I did some verification tests a while back, and it passed all of those I could think of at the time, but it wasn't a thorough effort and I plan to completely rewrite the emulation of this chip n the next version.

TmEE wrote:
On the TI PSG 0 produces lowest possible freq and 1 produces highest possible, and on SEGA VDP 0 is special cased to produce same output as 1. Those are not quite AY though lol.

Also interesting.

Rahsennor wrote:
Do I have to do anything special for a hotswap? Will a simple NROM that loads itself into RAM and spams sprite DMA until a button is pressed do the trick? Is there any way I can test it in an emulator?

If you want to test it in an emulator, make something that is a valid 5B ROM. (Only reason to use NROM for this is if it's a mapper your flash/dev cart doesn't support.)

Generally with hotswaps you have to use $2001 polling for timing. Polling in a a short loop tends to miss frames, so putting an extra wait in that loop can help.

For the swap wait, I generally just made buzzing noises with $4011 a few seconds apart to give myself time to swap. The buzz helps verify it's still running after the swap. I'm not sure if doing OAM DMA during the swap helps or not, but it's not a strict requirement or anything (I did many hotswap tests before hearing about the idea); it's also a convenient way to put a delay in your $2001 polling loop. In general I wouldn't do a "wait for input" thing, just because I like to compare to NSFs, but it's a valid way to synchronize too. I do recommend performing the whole test in a loop over and over again, so in case you swap late you can just wait until it comes around again.

Some old tests you might use as an example: http://rainwarrior.ca/projects/nes/swap_tests.zip


Top
 Profile  
 
 Post subject: Re: Stupid 5B questions
PostPosted: Sun Mar 25, 2018 6:27 pm 
Offline

Joined: Thu Aug 20, 2015 3:09 am
Posts: 414
TmEE wrote:
On the TI PSG 0 produces lowest possible freq and 1 produces highest possible, and on SEGA VDP 0 is special cased to produce same output as 1. Those are not quite AY though lol.

I knew I'd implemented both behaviours in an emu recently! Memory like a sieve, I have.

TmEE wrote:
Maximum attenuation on a channel does produce silence on a real AY (and the TI and VDP PSG). I haven't noticed any leakage effects.

Good to know, thanks. :beer:

rainwarrior wrote:
The old YM2149 emulator in NSFPlay appears to treat both period 0 and 1 as an "always on" silence.

That sounds suspiciously like a PCM-friendly ultrasonic suppression hack. I have seen that exact behaviour in emulators for the TI PSG, which doesn't have an always-on silence like the AY. (I have rips from two Tandy 1000 games that do PCM this way, and I'm sure there are many more.)

rainwarrior wrote:
If you want to test it in an emulator, make something that is a valid 5B ROM. (Only reason to use NROM for this is if it's a mapper your flash/dev cart doesn't support.)

Derp. It somehow didn't occur to me you can just use a Powerpack or something with actual FME7 support for this.

rainwarrior wrote:
Generally with hotswaps you have to use $2001 polling for timing. Polling in a a short loop tends to miss frames, so putting an extra wait in that loop can help.

I was just gonna cycle-time everything. That'll work, right?

rainwarrior wrote:
For the swap wait, I generally just made buzzing noises with $4011 a few seconds apart to give myself time to swap. The buzz helps verify it's still running after the swap. I'm not sure if doing OAM DMA during the swap helps or not, but it's not a strict requirement or anything (I did many hotswap tests before hearing about the idea); it's also a convenient way to put a delay in your $2001 polling loop. In general I wouldn't do a "wait for input" thing, just because I like to compare to NSFs, but it's a valid way to synchronize too. I do recommend performing the whole test in a loop over and over again, so in case you swap late you can just wait until it comes around again.

Some old tests you might use as an example: http://rainwarrior.ca/projects/nes/swap_tests.zip

Okay, I'll give it a shot. Might be a while before I can come up with anything, though, so don't hold your breath. Thanks for the help!

EDIT: also, I just realized that you can't modify the envelope shape while it's playing... writing register D resets the envelope! :roll: But that's another behaviour that isn't actually described in the official docs, albeit one all the emulators I've looked at agree on.


Top
 Profile  
 
 Post subject: Re: Stupid 5B questions
PostPosted: Sun Mar 25, 2018 9:01 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 6956
Location: Canada
Rahsennor wrote:
That sounds suspiciously like a PCM-friendly ultrasonic suppression hack. I have seen that exact behaviour in emulators for the TI PSG, which doesn't have an always-on silence like the AY. (I have rips from two Tandy 1000 games that do PCM this way, and I'm sure there are many more.)

Well, three candidate behaviours of halt (stay in current state), silence (flat 0 or full volume), and high frequency (alternating between both) are distinguishable even without being able to record high frequency sounds (the latter comes out as a "half" volume signal), so whichever the case this is easy to sort out with testing.

I hadn't thought about it being a too high frequency so my (weak) memory of 0 being "silent" should be correct by default if it is, since all three cases are technically silent. ;)

Rahsennor wrote:
rainwarrior wrote:
If you want to test it in an emulator, make something that is a valid 5B ROM. (Only reason to use NROM for this is if it's a mapper your flash/dev cart doesn't support.)

Derp. It somehow didn't occur to me you can just use a Powerpack or something with actual FME7 support for this.

Well, I had to use NROM for VRC7 tests, as I recall. Not 5B though.


Rahsennor wrote:
rainwarrior wrote:
Generally with hotswaps you have to use $2001 polling for timing. Polling in a a short loop tends to miss frames, so putting an extra wait in that loop can help.

I was just gonna cycle-time everything. That'll work, right?

That's an even better way to do it, since it's much more stable, no skipped frames. (Actually I should do this in my own tests, even a fixed "~16mz" delay with varying amounts of code run in between is still probably more desirable than a "vsync with chance of skip".)

Rahsennor wrote:
EDIT: also, I just realized that you can't modify the envelope shape while it's playing... writing register D resets the envelope! :roll: But that's another behaviour that isn't actually described in the official docs, albeit one all the emulators I've looked at agree on.

You can change its pitch, but yes it necessarily has to have a phase reset mechanism because most of the envelope modes are 1-shot.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group