Jump to content
IGNORED

Polycounter Reset on Pokey


analmux

Recommended Posts

Would be interesting to punch in Bryan if your willing to share and it's not too much to post.... :?:

 

I will as soon as I get the chance. I was going to write up a bigger Pokey document since I've spent some time reverse engineering it, but that may not happen for a long time. :(

Link to comment
Share on other sites

Nice.

 

So, I guess you kinda "lose" the use of one voice in order to get the waveform?

 

I looked at it in Audacity - near perfect triangle (for the bloop-bloop at the end).

 

Looking forward to the description of the method.

 

Yes. With Pokey you always seem to lose a voice doing something cool. Of course, you started with one more than many early sound chips anyway. :)

 

The triangle effect uses at least two voices and doesn't produce a very loud signal, but it can also be done by combining three or four voices for a boost in output.

Link to comment
Share on other sites

Triangle is quiet in any case, except at higher frequencies.

 

How is that done? Multi voices on similar frequencies with different volume?

 

I've been playing around a bit, and had very little success.

 

What serial mode is used in $D20F?

 

I'd be interested in hearing just how it is you vary the duty cycle, and generate a triangular wave.

Link to comment
Share on other sites

I've got the triangle wave going.

 

Assume yours is also just playing voice 1 and 3 with adjacent frequencies at 1.77 MHz clocking?

 

Yes, when the two voices are in phase they produce a fast square wave that averages to some value (simple PWM). When they are out of phase, they produce a different average based on the analog mixing of the output. Since the triangle alternates between these two mid-values, it isn't very loud. What I did discover is that you can set one or both of the channels to be 16-bit, and enable the volume outputs of both halves. I seem to recall I was able to boost the volume quite a bit when I did this correctly.

 

I was looking for my source for the sound effect experiments, and I'm not sure where I put it. I'm at work, but I'll look tonight.

Link to comment
Share on other sites

I seem to recall I was able to boost the volume quite a bit when I did this correctly.

 

Hmpf.... a long ime ago I did also some test with the triagle waves. I remember to have them at a good volume... I needed all four voices to have the bass (with four standard wave generators) as loud as the triangle.

And, I remember (non atari related) people listening to it, recognizing a real flute. Not the triangle and not what you hear inside my RMT experiments.

Since it's around 17 years ago, I really do not remember correctly how I did it. But I remember having a basic program with notes entered by data, playing in the VB.

Edited by emkay
Link to comment
Share on other sites

Interesting sampling it at 200KHz.

 

There is actually "flanging" which changes the characteristics of the wave a bit, but it occurs so fast that it is virtually unnoticable in many frequencies.

 

e.g. with Voice 1/3 at dec. 60/61, the flanging range is .005 seconds apart.

 

 

Still very interested in knowing about these square waves with settable duty cycle.

 

 

post-7804-1196094422_thumb.jpg

Edited by Rybags
Link to comment
Share on other sites

I found another interesting feature in Pokey that allowed me to make a square wave with any duty-cycle between 25 and 50%. You could even slide gradually between them making a cool flange effect. I don't have all the info in front of me but it involves enabling the two-tone (cassette) mode, then using one (silent) voice to reset the counter of the other. I had a simple calculation to generate any pitch and duty cycle.

 

I wrote some sound effects that use this trick (and the amplified 3-voice triangle trick) that I hope to use in a game someday.

 

Some Pokey feature which is still a bit of a mistery to me is the so-called '16bit filter' effect. Some features resemble real analogue filtering a lot.

 

Normally, the following would give you a triangle wave:

 

P=53760
POKE P+8,64+32
POKE P+1,170:POKE P+5,170
POKE P,39:POKE P+4,40

 

It wastes 2 channels, and it gives a slightly quiet sound.

 

Indeed the 3channel option is available:

P=53760
POKE P+8,64+32+16
POKE P+3,170:POKE P+5,170
POKE P+2,0
POKE P,36:POKE P+4,40

POKE P+1,170

 

the 16bit-filtering feature is now giving a boost.

 

Note: This is also possible in a wide variety of other situations, f.e. 16bit bass notes.

Normally when 16bit is used: join channel 1&2 it is sufficient to keep ch.1 silent and ch.2 non-silent.

When also ch.1 is non-silent you can add so-called extended harmonic content, because the combined 16bit timer also has an effect on independent timer of channel 1.

 

The following piece of code sounds like a high-pass filtering effect:

 

P=53760
POKE P+8,64+32+16
POKE P+3,170:POKE P+5,170:POKE P+2,0
POKE P,36:POKE P+4,40

FOR Z=0TO999:FOR Y=0TO15:POKE P+1,175-Y:FOR Q=0TO8:NEXT Q:NEXT Y:NEXT Z

 

...but, another application of the 16bit filter is the following: this feature is often used in demo tunes:

 

P=53760
POKE P+8,16
POKE P+3,170:POKE P+2,2

FOR Z=0TO999:FOR Y=0TO15:POKE P+1,175-Y:FOR Q=0TO8:NEXT Q:NEXT Y:NEXT Z

Link to comment
Share on other sites

Still very interested in knowing about these square waves with settable duty cycle.

 

Okay, here's what I remember. When you set bit 3 of SKCTL, you enable 2-tone mode. This allows you to set two frequencies to be sent out to the cassette recorder. One interesting feature of this mode is that one of the counters actually resets the other (I assume this has something to do with aligning the phase of the two tones- maybe it depends on the current serial bit state- I've forgotten). So, normally the counter counts down, the output bit flips, and the counter counts down again. In this mode you can make the counter count down, the output will flip, then the counter starts counting down again but is reset by the other (slower) channel and both counters start over. This extends the time it will take for the 2nd half to reach zero, and viola! - settable duty cycle. If you set the 2nd channel too fast, it affects both halves of the cycle, gaining you nothing. If you set it too long, it affects every 3rd or 4th half-cycle (which may be useful). You'll want to turn off the output of the channel actually doing the resetting, since I haven't found a use for mixing it in yet.

 

Also, you can't do any serial communications while doing this.

Edited by Bryan
Link to comment
Share on other sites

Still very interested in knowing about these square waves with settable duty cycle.

 

Okay, here's what I remember. When you set bit 3 of SKCTL, you enable 2-tone mode. This allows you to set two frequencies to be sent out to the cassette recorder. One interesting feature of this mode is that one of the counters actually resets the other (I assume this has something to do with aligning the phase of the two tones- maybe it depends on the current serial bit state- I've forgotten). So, normally the counter counts down, the output bit flips, and the counter counts down again. In this mode you can make the counter count down, the output will flip, then the counter starts counting down again but is reset by the other (slower) channel and both counters start over. This extends the time it will take for the 2nd half to reach zero, and viola! - settable duty cycle. If you set the 2nd channel too fast, it affects both halves of the cycle, gaining you nothing. If you set it too long, it affects every 3rd or 4th half-cycle (which may be useful). You'll want to turn off the output of the channel actually doing the resetting, since I haven't found a use for mixing it in yet.

 

Also, you can't do any serial communications while doing this.

 

I did a try. It seems to work when you also put bit 7 of SKCTL to a logical 1.

Link to comment
Share on other sites

amazing. Pokey still has a lot of surprises for me

 

Mux,

 

Atari should have helped programmers figure this out from the start. Could you imagine if we could send some modern A8 libraries back in time? Imagine how good software would have been back in '80-82.

 

-Bry

 

Edit:

 

Here's my best attempt at the main Pac-Man tune (using triangle and 5-bit poly, I believe).

Pokeytune.mp3

Edited by Bryan
Link to comment
Share on other sites

Mux,

 

Atari should have helped programmers figure this out from the start. Could you imagine if we could send some modern A8 libraries back in time? Imagine how good software would have been back in '80-82.

 

-Bry

 

Thus, to summarize:

 

The 2-tone-filter can be used by doing the following:

1) setting bit 3 of SKCTL to select 2-tone-filter

2) setting bit 7 of SKCTL: this is the forced output of the serial port. setting this will put a logical 0 to the serial port. This selects sound of channel 2 instead of channel 1.

3) putting AUDC2 to silence

4) selecting desired AUDC1 settings

5) selecting a desired pitch: write to AUDF2

6) selecting a desired 2-tone-filter setting: write to AUDF1

 

So, can I assume that channel 3 & 4 are not affected by using 2-tone-modus? Then we'd still have 3 overall channels in total. This is quite acceptable, since most fancy Pokey settings (filter and 16bit) also eat a channel.

 

I think this whole 2-tone-filter trick is very similar to the 16bit-filtering modus: then channel 1 is also 'corrected' by channel 2 timer.

 

I wonder. What would a (Pokey-) musician do with this knowledge?

 

 

---------------------------------------------------------------------------

As far as I can see, this is just the beginning of a beautiful frenzy

Link to comment
Share on other sites

Last year I did some research with Piotr Fusik about Pokey and he made documentation about what we found:

http://asap.sourceforge.net/pokeydoc.zip

He has put this info into his ASAP Pokey player, so you can look at the source to that:

http://asap.sourceforge.net

This info is based on the Pokey internal schematics and test programs.

There is still a lack of info about how the analogue circutry works.

 

Thanks for sharing. I had a look at it. Looks interesting.

 

Though, how about a part about 16bit filtering and 2-tone-mode filtering? :)

 

anyway, what should I do with the .xml files??...as they look incomplete or something.

Link to comment
Share on other sites

But what did you do exactly then? How did you call the subroutine? Did you activate it on a scanline where gfx is displayed?

I showed routine from RMT with settings of AUD-F/C/CTL.

Maybe I made something wrong, please, recommend me right method of changes for reseting polycounters. Thank you very much.

 

The rules for Polycounter reset/offset control are the following:

 

1) Only do it ONCE, at the start of a note

2) be sure that it's executed at a fixed DMA scheme: this is obtained when the reset-subroutine is executed at a time when there's no screen DMA, i.e. above the top of the screen or below the bottom.

 

thus, the reset-routine should, for any pokey-tracker, be regarded as a separate process, triggered by a separate IRQ, DLI, VBI or other timing technique. In my demo it is automatically processed at the right moment.

 

Be aware. It doesn't work on emulators (also note that the 2-tone-mode filter doesn't work in emulation)

 

I've noticed that once polycounters are reset, they maintain nearly 100% stability even when notes are changed.

Edited by Analogue Multiplexer
Link to comment
Share on other sites

The rules for Polycounter reset/offset control are the following:

1) Only do it ONCE, at the start of a note

Ehm, I'm afraid of I can't solve this. Instruments are too complicated and they can be playing simultaneously in various combinations/loops/envelopes to discern some "start of note only" moments. :-(

2) be sure that it's executed at a fixed DMA scheme: this is obtained when the reset-subroutine is executed at a time when there's no screen DMA, i.e. above the top of the screen or below the bottom.

thus, the reset-routine should, for any pokey-tracker, be regarded as a separate process, triggered by a separate IRQ, DLI, VBI or other timing technique. In my demo it is automatically processed at the right moment.

IMHO it seems to be solvable in some laboratory sound experiments or special cases, but not in common songs inside "normal" games etc.

So, although It's very interesting, I don't see the way to implement polycounters reseting to rmt player routines at present. :|

Link to comment
Share on other sites

Humm... I wrote my Pokey routines back in 2005, and I had a HD crash that I was able to (mostly) recover from, but I can't find the sound source code. It will be a bummer if I don't find it since I had an almost complete set of improved Pac-Man sound effects, plus routines to demonstrate other interesting effects.

 

I'm glad Mux was able to write an example to get people started messing with it, though.

Link to comment
Share on other sites

The rules for Polycounter reset/offset control are the following:

1) Only do it ONCE, at the start of a note

Ehm, I'm afraid of I can't solve this. Instruments are too complicated and they can be playing simultaneously in various combinations/loops/envelopes to discern some "start of note only" moments. :-(

 

But, to be honest, I think you see far more problems than there are actually.

 

IMHO it seems to be solvable in some laboratory sound experiments or special cases, but not in common songs inside "normal" games etc. So, although It's very interesting, I don't see the way to implement polycounters reseting to rmt player routines at present. :|

 

:roll: ...well, what to say??

 

I'm sure it's possible to do, also in just a music tracker for tunes just used in games.

 

Isn't it so that RMT player knows when a note starts?

Edited by Analogue Multiplexer
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...