It is currently Mon Jul 15, 2019 7:24 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 46 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
PostPosted: Thu Mar 28, 2019 9:34 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 7525
Location: Canada
tepples wrote:
rainwarrior wrote:
I don't think I'd tested this before, but using a value of 0 for the envelope's period does not halt it. It will instead behave exactly as if its period value was 1. (I have been told that the square wave tones do this as well, but the resulting frequency is above audible and I haven't verified with a scope.)

Could you make a tone by bit banging the log volume of an ultrasonic (period 0 or 1) wave and then compare the volume of that tone to other volumes you can coax out of the chip?

You're going to have to explain a bit more about how this would measure its frequency. (I can't control its phase, if that's what you were thinking.)

I'm pretty sure that I've verified in the past that it doesn't halt, and that it makes output (when trying to see if it would reset phase). The unverified part is just the frequency.

The only reasonable idea I have for this frequency is that it's a duplicate of period 1 (56 kHz), which would be consistent with the envelope and noise and some other emulator implementations I've seen. 0 as a value doesn't work as a division, obviously. I don't know what's left to consider otherwise? It's above audible. It's not zero. So... it's either equivalent to 1 or 2, or it's something else out of left field.

If I could generate some other frequency close to it but slightly different maybe I could get it to heterodyne, but everything is dealing with divisions of the same clock... maybe $4011 has a chance there?

...or I could just measure it with a scope, probably. :P

Either way, if it isn't 1 the difference is probably going to be too trivial for most emulators. One inaudible result is probably as good as the next. :P


Top
 Profile  
 
PostPosted: Thu Mar 28, 2019 10:11 am 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 8475
Location: Seattle
If your soundcard is new enough to actually really support recording at 192kHz, you can probably still use it.


Top
 Profile  
 
PostPosted: Thu Mar 28, 2019 10:18 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 21501
Location: NE Indiana, USA (NTSC)
rainwarrior wrote:
tepples wrote:
Could you make a tone by bit banging the log volume of an ultrasonic (period 0 or 1) wave and then compare the volume of that tone to other volumes you can coax out of the chip?

You're going to have to explain a bit more about how this would measure its frequency. (I can't control its phase, if that's what you were thinking.)

It's enough to demonstrate the distinction between halt and halfway, at least good enough for testing an emulator. Also try feeding a small amount of ultrasound into the video signal and seeing how big the additive interference bars are. (Horizontal sync in LD/SDTV is close to 15.7 kHz.)

_________________
Pin Eight | Twitter | GitHub | Patreon


Top
 Profile  
 
PostPosted: Thu Mar 28, 2019 1:05 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 7525
Location: Canada
tepples wrote:
It's enough to demonstrate the distinction between halt and halfway, at least good enough for testing an emulator.

That part is already known, the only remaining detail is the exact frequency, which I have no good reason to suspect is anything but 56 kHz.

tepples wrote:
Also try feeding a small amount of ultrasound into the video signal and seeing how big the additive interference bars are. (Horizontal sync in LD/SDTV is close to 15.7 kHz.)

??? How does one "feed" ultrasound into the video signal?

lidnariq wrote:
If your soundcard is new enough to actually really support recording at 192kHz, you can probably still use it.

Sometimes I forget that I might have devices that do extra high frequencies like that. That's potentially a really good solution though, with a good effort vs. importance-of-knowing-this-particular-piece-of-trivia tradeoff. ;)


Top
 Profile  
 
PostPosted: Thu Mar 28, 2019 1:47 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 7525
Location: Canada
Okay, so the Realtek sound device on my desktop computer indeed does 192 kHz. The high frequencies were very attenuated, but still enough was there to verify confidently that indeed tone period 0 is remapped to tone period 1.

I also verified that noise period 0 is remapped to noise period 1 while I was at it.

I also measured the repetition of noise at ~2.37s at 56 kHz ~= 2^17 so that should verify that the LFSR is 17 bit.

So... nothing interesting, just confirmation of things that had been strongly presumed true already. (Relevant tests were added to noise_5b.)


Top
 Profile  
 
PostPosted: Thu Mar 28, 2019 2:04 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 7525
Location: Canada
Just one more confirmation: the LFSR described on the wiki is correct. 17 bits, taps at 13 and 16.

Attachment:
5b_LFSR_vs_NSFPlay.png
5b_LFSR_vs_NSFPlay.png [ 25.76 KiB | Viewed 5202 times ]

NSFPlay's current implemenation perfectly matches the recorded noise bit stream. (MAME's LFSR looks equivalent.)


Top
 Profile  
 
PostPosted: Thu Mar 28, 2019 2:58 pm 
Offline
User avatar

Joined: Wed Feb 13, 2008 9:10 am
Posts: 696
Location: Estonia, Rapla city (50 and 60Hz compatible :P)
You can always underclock the relevant parts, most of these devices are static and won't mind running at significantly lower clocks.

_________________
http://www.tmeeco.eu


Top
 Profile  
 
PostPosted: Thu Mar 28, 2019 3:29 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 7525
Location: Canada
Yes, that's another theoretical option.

It would be an extremely disproportionate amount of electronics work to answer that question, though. Especially since it was mostly inconsequential, and we almost certainly already knew the answer. (...and a few posts up I confirmed that we did already have the answer.)

Like just using a scope would have been even easier than that. I probably would have done that if lidnariq hadn't pointed out that my sound device can do higher frequencies. Was really more about finding a time and place to slip a test for this in with the other stuff I was working on.


Anyhow, sorry to clutter up byuu's thread with that. I just wanted to confirm those last few things about the 5B that I hadn't gotten around to verifying yet. For the purposes of his question, I can say a lot of things with certainty about the 5B, and as far as I've seen it corresponds exactly to a YM2149F (with SEL low).

I haven't personally tested YM2149F or AY hardware at this point, but I've had a ton of second-hand confirmation of how they work, so my knowledge of them isn't totally based on emulators, but I hope I've made it clear what things I have explicit first-hand knowledge of, and what I only know from others' work. (I can back up everything on the wiki page about 5B audio.)

I might some time in the future set up a board to test a real AY and/or YM2149 (when resource/time/interest aligns), but at the moment I'm able to directly run tests on the 5B at least, and any lack of correspondence between that and a YM2149F would be a huge surprise. (I'm personally out of hanging questions about the 5B though, everything on my list to check is now verified.)


Top
 Profile  
 
PostPosted: Fri Mar 29, 2019 12:37 am 
Offline

Joined: Thu Aug 20, 2015 3:09 am
Posts: 457
Had to dredge up my last stupid topic on the subject to jog my memory, but it looks like you've crossed off all of my edge cases too - except for what happens when you write to period registers in-flight, to confirm the chip counts up like the MAME code says. But periods 0 and 1 being identical strongly suggests that's the case anyway.

(The issue I reported of some VGMs playing different pitches for noise period zero turned out to be a bug in the reference VGM player - it masks out the high bits of the noise period register after special-casing zero, resulting in a low pitch instead of a high pitch for VGMs that write garbage to those bits. But I overzealously masked them out before my debug printouts, so I saw two identical logs playing two different sounds. Herp.)


Top
 Profile  
 
PostPosted: Fri Mar 29, 2019 5:19 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 7525
Location: Canada
Ah, yes I do believe you will see an immediate flip if you lower the period during a longer wave, prematurely ending that half-wave. I think I verified this when I was testing that 50/50 "phase reset" trick earlier, but it's a thing I can't find my records of if I actually did it. (I have a memory of doing it... but why didn't I post it anywhere if I did??)

Anyhow, will write a test for that and run it. I think the most sensible implementation of the counters is increment the phase and >= with the period value each tick. What NSFPlay is doing for this is almost certainly wrong.

(That reminds me I need to test what N163 does when you cut down a long wave too.)


Top
 Profile  
 
PostPosted: Fri Mar 29, 2019 9:20 am 
Offline

Joined: Mon Mar 27, 2006 5:23 pm
Posts: 1497
> Anyhow, sorry to clutter up byuu's thread with that.

Nah, go for it! Anything that improves emulation is great. Thanks for your hard work!

On my own front, I spent today greatly improving my Z80 core, and I have good audio from MSX games now, so I just need to find a good MSX1 game that uses the envelopes extensively.

> NSFPlay's current implemenation perfectly matches the recorded noise bit stream. (MAME's LFSR looks equivalent.)

I am surprised the chosen taps end up equivalent. I remember them being quite picky on the Neo Geo Pocket.

> I'm personally out of hanging questions about the 5B though, everything on my list to check is now verified.

Only thing I can think of at the moment is to get precise measurements of the 32 possible volume states, but it's not super important now that we're past the days of treating the volume as being linear, heheh.


Top
 Profile  
 
PostPosted: Fri Mar 29, 2019 9:29 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 7525
Location: Canada
One more test ROM (phase_5b) to verify those two things, as well as another question about the envelope that I realized was open after re-reading what byuu was asking about its volumes.

1. When you change from a long period to a short one, the shorter period takes effect immediately. It does not wait for the next flip.

i.e. the "phase counts up, flips and resets when >= period" behaviour should be correct.

2. Volume 0 is indeed silent.

i.e. it's not like VRC7's logarithmic attenuation where maximum attenuation of a channel is just very quiet and not silent.

I was almost completely sure of both of those things, but hadn't ever properly documented a test of it.


3. Envelope volume 0 and 1 are both silent. Envelope (YM) 31 = tone (AY) volume 15.

Byuu had been asking whether the envelope volumes are in between, and after thinking about it I realized the ambiguity that was created by it having 32 steps.

The YM datasheet actually has a graph that depicts the voume 15 being equal to tone 31, but 0 was a bit ambiguous on that scrunched graph. Though we should probably always be suspicious of datasheet diagrams. ;)

So with the clarification that envelope volume 0 and 1 are the same, the rest seems to follow logically: every odd step of the 5-bit envelope output is equivalent to a 4-bit volume setting. 1=0, 3=1, 5=2... 27=13, 29=14, 31=15. The others are in between, and 0 is clamped back to 0.


Top
 Profile  
 
PostPosted: Fri Mar 29, 2019 9:39 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 7525
Location: Canada
byuu wrote:
I am surprised the chosen taps end up equivalent.

They're the exact same taps / LFSR operation. It's just expressed slightly differently.

(I assume they came from the same information source. I don't remember if I had put that into NSFPlay after hearing about a decap, or whether it was there before...)

byuu wrote:
Only thing I can think of at the moment is to get precise measurements of the 32 possible volume states, but it's not super important now that we're past the days of treating the volume as being linear, heheh.

See the post above for the relationship between fine envelope and volume.

As far as exact measurements, 5B won't apply to YM because it has its own internal amplifier, and it depends on the total mix rather than the output of a single channel independently.

So... what I have measured seemed to match a model of the specified 1.5 db per step + the 5B's nonlinear curve very well. I couldn't say whether the AY/YM achieve a perfect 1.5db or if their logarithmic DAC has its own typical curve, but 1.5 db seemed close enough to accurately describe the 5B output (with the secondary amplifier characteristics on top). Every step measured pretty close to 3.0 dB before it hit the nonlinearity.

There were some graphs of this in my other thread here: 5B amplifier research (note that I incorrectly though it was a compressor at the time, and not just a nonlinear amp)


Top
 Profile  
 
PostPosted: Fri Mar 29, 2019 11:43 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 7525
Location: Canada
Added one more set of tests to phase_5b. Just a verification that the tones, the noise, and envelope are never halted. All of them are continually active whether or not they're connected to an audible output.

Things that have been verified not to halt things:
  • Volume 0 does not halt tone or noise
  • Tone disable bit ($07) does not halt tone
  • Setting all 3 noise disable bits ($07) does not halt noise
  • Clearing all 3 channel volume envelope bits does not halt envelope
  • Period value of 0 does not halt any of these (treated as period 1 in all cases)

So basically just everything continues cycling at all times. I can't really think of any other stuff that might potentially halt something on here.

Again, was pretty sure, but it's common to see emulators halt things that aren't doing anything... I think that's a tempting implementation "optimization", but it's wrong here if you want accuracy. Though it's not really that big a deal, since envelope phase has an explicit reset, and noise/tone phase is anything but guaranteed with this thing.


Top
 Profile  
 
PostPosted: Fri Mar 29, 2019 5:00 pm 
Offline

Joined: Thu Aug 20, 2015 3:09 am
Posts: 457
For those who don't know, there are two ways of implementing an LFSR: Fibonacci and Galois. You can convert from one form to the other without changing the output by simply reversing the order of the taps. (Note that the internal state is not equivalent, so you may have to do a bit of juggling to get it to start at the same point.)

For example, my implementation of the AY-3-8910 LFSR is:
Code:
   lsb = lfsr & 1;
   lfsr >>= 1;
   lfsr ^= (-lsb) & 0x12000;

You can easily verify if a given conversion produces the same output sequence by brute force.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 46 posts ]  Go to page Previous  1, 2, 3, 4  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 2 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