Jump to content
IGNORED

POKEY 16-bit mode and other AUDCTL settings - A7800 emulation


Recommended Posts

It's kind of a cancellation through phasing.  A subtractive filter.  For example, if both squares play at the same period and frequency:

 

___|"""|___

"""""|__|""""

 

They cancel each other out and you get near silence.

 

But delay one by a cycle:

 

___|"""|___

""""|__|""""|

 

The duty cycle pulse wave is created, and the more cycles apart the waves are, the wider the pulse.  This emulates the NES function.

 

By stepping either frequency up or down a step, makes a swirling tone because of the differing wavelengths. 

 

The trick is in maintaining the cycle.  In my music routine, the oscillators tend to drift.  It may require a timer reset each time a note is played.

Edited by Synthpopalooza
  • Like 1
Link to comment
Share on other sites

I believe the Phasing done by TIA is of an additive sort.  POKEY can do this too, for example, playing two square notes an octave apart creates a 50% duty cycle pulse, via additive phasing.   If you listen to the Bentley Bear music you will hear this effect in the lead sound halfway through the tune.

 

What the hi pass filter does, is in a subtractive capacity.  The cycle of the third channel filters out elements of the first one.

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...

OK, more tests ... using new settings.

 

First up, is a rendition of the Stranger Things theme.

 

This one uses the following settings:

 

AUDCTL=$F1 (16 bit mode on 0 and 1, main clock 15 khz, clock 0 and 2 at 1.79 mhz, 9-bit polycounter)

 

0: $8x - 9-bit polycounter at 1.79 mhz, 16-bit mode reversed, distorted guitar sound

1: silenced - modulates the vibrato of channel 0

2: $2x triangle wave- at 1.79 mhz.  melody sequence.

3: $Ax square wave- at 15 khz.  Bass sequence.

 

An explanation of these settings:

 

15 khz mode basically transposes all four channels down two octaves, allowing $Ax square wave to be used as a bass instrument without requiring 16-bit mode.  The standard $Ax square wave 8-bit note table is used, but transposed down two octaves.  15 khz mode will not affect any channels clocked with 1.79 mhz, which means you can use $2x clocked at 1.79 mhz to play your higher leads here.

 

Channels 0 and 1 are the new feature here.  It is a reversed 16-bit setting using the $8x on 9-bit polycounter at 1.79 mhz, same as the Rolling Thunder demo, but with an entirely new note table shown below:

 

c1	142	212
c#	148	201
d	154	189
d#	159	178
e	164	168
f	169	160
f#	173	152
g	178	141
g#	182	133
a	185	127
a#	189	119
b	192	113
c2	195	107
c#	198	101
d	201	95
d#	204	89
e	206	85
f2	209	79
f#2	211	75
g	213	71
g#	215	67
a	217	63
a#	219	59
b	221	55
c3	222	53
c#	223	51
d	225	47
d#	227	43
e	228	41
f	229	39
f#	230	37
g	231	35
g#	232	33
a	233	31
a#	234	29
b	235	27
c4	236	25

 

Basically, channel 0 carries the frequency, but channel 1, when varied by a few steps above or below the indicated value, will introduce a warbling vibrato effect to the guitar!

 

A note:  I have not yet figured out how to silence the zero frequencies (meant to be note rests), so they will unfortunately play.  If anyone can look at the code, i'd appreciate it.  I know @RevEng gave me some modifications for this, but they destroyed the timing of the track.  More work needed I guess.

 

Emulation notes:  This time it is a mixed bag.  Prosystem plays the tune ok but won't do the 9-bit poly, so you hear white noise.  A7800 actually plays this well too, except the 2nd $2x channel is played an octave too high, and the $8x 9-bit poly is actually done, but sounds more out of tune than on real hardware.  However, the 15 khz clock works correctly in both emulators!  Yaay :)

 

Binaries below, @$4000 and @$450 for POKEY.  Test these out please.  Also a .wav recording from Altirra.

strangerthings-450.A78 strangerthings-450.asm strangerthings-450.bin strangerthings.A78 strangerthings.asm strangerthings.bin strangerthings.wav

Edited by Synthpopalooza
  • Like 1
Link to comment
Share on other sites

Now, for the second test:  Also from Stranger Things, the very eerie "Upside Down" theme music.

 

These are the settings used:

 

AUDCTL=$23 - 15 khz master clock, 1.79 clock on channel 2, hi pass modulation of channel 1 from channel 3.

 

Channel 0:  $Ax square at 15 khz - bass hit.

Channel 1:  $Ax square wave sequence hit at 15 khz - modulated from channel 3

Channel 2:  $Cx sawtooth at 1.79 mhz

Channel 3:  Silenced.  Frequency modulator for channel 1

 

So, to explain:  15 khz again sets all the standard $Ax square channels down two octaves, enabling bass frequencies to be played.

 

On channels 1 and 3, we get a good demonstration of the mis-named hi-pass filter.  In this case, we get an emulation of the NES duty cycle.  Here's how it works ... You play the identical frequency on both 1 and 3.  By delaying the start of the frequency on channel 3, you put the oscillators out of sync and generate a duty cycle pulse sound.  The further the delay, the further the width of the pulse wave.

 

If you use the setting where the frequencies are the same, but you set the second frequency to a step above or below the first, you get a swilrling synth tone.  This method is used part way into the tune.

 

Further in, the tune switches to a very low bass sequence, which is achieved by setting channel 3 to play 5 semitones above the first channel, with frequencies taken from this table below, a slight modification of the standard $Ax 8-bit note table:

 

AUDCTL=$04 AUDC1=$Ax AUDC2=$00

Uses these intervals.

AUDF1=AUDF2
AUDF1=AUDF2+4 semitones
AUDF1=AUDF2+7 semitones
AUDf1=AUDF2+12 semitones (one octave) ... pulse wave

AUDF2=AUDF1+5 semitones
AUDF2=AUDF1+7 semitones
AUDF2=AUDF1 + octave

These are the best settings to produce musical tones.  Other settings will produce noise.

 

In this case, the pulse width gradually and randomly changes as the tune progresses.  It is possible to set the pulse width at will, by playing a zero frequency a set number of cycles and then re synch-ing the oscillators.

 

Channel #2 is $Cx set to 1.79 mhz ... high frequency notes, which are used for a high arpeggio in the middle of the tune.

 

Again, I haven't solved the zero frequency whine problem ... still working on that unfortunately.

 

Emulators:  Surprisingly, A7800 plays this nearly flawless!  The pulse width varies a bit more than actual hardware, but everything else is spot on.  Prosystem in this case completely botches the modulation, you just hear a constant square wave throughout.

 

Binaries and sources for both $450 and $4000.  Tests on real hardware are always appreciated ... as are tips on how to kill those zero frequencies!

 

 

 

 

upsidedown.A78 upsidedown.asm upsidedown.bin upsidedown-450.A78 upsidedown-450.asm upsidedown-450.bin upsidedown.wav

Edited by Synthpopalooza
  • Like 1
Link to comment
Share on other sites

On 10/23/2019 at 8:14 PM, Synthpopalooza said:

Now, for the second test:  Also from Stranger Things, the very eerie "Upside Down" theme music.

  Tests on real hardware are always appreciated ...

 

Found something interesting when recording this one - unsure if it is intentional or not.  Every time I pressed 'Reset' to start the demo it began in a different key/frequency.  I've attached two mp3s. 

 

Part 1 is running the demo with me pressing reset every 2-3 seconds.

 

Part 2 is just a straight playback of the demo after the console was powered off for ~5 minutes:

 

Stranger Things Upside Down Theme Music - Real HW PT 2.mp3Stranger Things Upside Down Theme Music - Real HW PT 1.mp3

  • Like 1
Link to comment
Share on other sites

3 hours ago, Trebor said:

 

Found something interesting when recording this one - unsure if it is intentional or not.  Every time I pressed 'Reset' to start the demo it began in a different key/frequency.  I've attached to mp3. 

 

Part 1 is running the demo with me pressing reset every 2-3 seconds.

 

Part 2 is just a straight playback of the demo after the console was powered off for ~5 minutes:

 

Stranger Things Upside Down Theme Music - Real HW PT 2.mp3 5.18 MB · 3 downloads Stranger Things Upside Down Theme Music - Real HW PT 1.mp3 1004.51 kB · 3 downloads

Yes.  That is because the phasing of the oscillators (channels 1 and 3) is not constant.  Looking for a way to stabilize this.

  • Like 1
Link to comment
Share on other sites

6 hours ago, Synthpopalooza said:

Yes.  That is because the phasing of the oscillators (channels 1 and 3) is not constant.  Looking for a way to stabilize this.

 

If you play the depending channels for some cycles at the highest tone, the result gets 99% stable .

 

in 15khz

 

 

and in 64kHz

 

 

Link to comment
Share on other sites

Listening to the reset version of the tune,  what you are hearing are the different duty cycles generated by varying phases of the oscillators... both play the same frequency, but the different phasing of the third oscillator is what generates the varying duty cycles.

 

Going to try some tricks on it to improve it.

Link to comment
Share on other sites

Both channels put together for (filter) , then play the highest pitch on both .

If you write your own code, you have to assure that POKEY is really playing the high peak.

If you use channel 0 and 2 , you could set them to 1.79MHz for speeding up things.

Using 15kHz it may need a quarter frame.

In RMT it is always a full VBI Cycle, as the editor doesn't support it. You can also speed things up there, if the engine runs at 2 ,3  or 4 times VBI speed.  

In the later tunes I'm doing the "reset" in low volume parts or when short pauses allow it.

  • Thanks 1
Link to comment
Share on other sites

  • 4 months later...

Resuming the experiments ... :)

 

I am now playing around with $4x distortions in 1.79 mhz settings.  This creates some harsh bass sounds.

 

Like $Cx, there are two modes in $4x ... when using frequencies divisible by 3, a less harsh tone can be had, although again you get three random timbres.

 

This setting can be used in 16-bit mode, but the only advantage is three extra notes on the low end.

 

Demo coming soon.  ?

  • Like 3
Link to comment
Share on other sites

Demo complete ...

 

This is a rendition of the Deep Purple song "Smoke On The Water"

 

The following settings were used:

 

AUDCTL=$F0 - 16 bit filter on 0 and 1, clocked at 1.79 mhz, 9 bit poly counter, channel 2 clocked at 1.79 mhz

 

0 and 1:  $8x, reverse 16-bit filter, 1.79 mhz clock, 9-bit polycounter - distorted guitar

2:  $4x, clocked at 1.79 mhz - bass

3:  $Ax, no special settings - standard square wave

 

This is my first experiment with the $4x distortion.  Normally this is not used musically, but with a 1.79 mhz clock, bass frequencies become usable.  Like in the $Cx distortions, 2 frequency tables are in use:

 

Distortion 4a:  Frequencies where (freq+1) mod 3  <> 0.  These frequencies produce harsh bass sounds.  The timbre sounds close to the snarling sound Donkey Kong makes in the Atari 8-bit port of Donkey Kong

 

Distortion 4b:  Frequencies where (freq+1) mod 3 = 0 and (freq+1) mod 5 <>0.  This produces a less harsh bass timbre.  Like in 12b, random timbres are produced, depending on system timers.

 

Also, like in the $Cx distortions, a $0E frequency produces silence.

 

Some thoughts:  This can be used in either 8-bit or 16-bit mode, but 16-bit mode does not confer any special advantages, apart from six extra notes on the low end for Distortion 4b.  You have an effective frequency range in 4b from about F#1 up to about the 3rd octave before tuning errors set in.  4a lets you go down to C1, but has a lower top range, up to about A2. 

 

Notes for this channel are taken from my POKEY note table, distortion 4b, 8-bit mode.  Because this setting will not play below F#1, the F1 note used comes from the 4a table.

 

On channels 0 and 1, $8x with 9-bit poly is used, in reverse 16-bit mode, where channel 0 plays, and 1 is silenced.  The note table used here is the same as for the Stranger Things demos.  This creates the distorted guitar sound.  Channel 3 plays a stardard $Ax square wave which makes the lead sound.

 

Emulators:

 

Emulators are a mixed bag.  Both fail at this.  Prosystem comes closest, the bass and lead channel play properly, but the 9-bit poly is not done on the $8x channel, so white noise is heard.  On A7800, noise is heard on the bass channel, except for the F1 note, and the $8x channel notes are played very noticeably out of tune.

 

Binaries are below (for POKEY @$450 and @$4000), in addition a .wav file recorded from Altirra, which of course does the music flawlessly.  Tests on real hardware, as always, are appreciated.

 

Next steps:  Doing some revisions to the POKEY note table, to add in the new reverse 16 and SKCTLS settings.  These will be added on seperate pages.

 

 

 

 

smokewater-450.A78 smokewater-450.asm smokewater-450.bin smokewater-4000.A78 smokewater-4000.asm smokewater-4000.bin smokewater.wav

Edited by Synthpopalooza
  • Like 3
  • Thanks 1
Link to comment
Share on other sites

Documented another setting ... at least partially.

 

AUDCTL=$40 (1.79 mhz on 0)

SKCTLS=$8B (two tone mode)

 

Channel 0 :$4x distortion, modulation of frequency for 1

Channel 1: Silent, frequency carrier for 0

 

This is a lot to go into here, but I made an extensive post here:

 

 

We are dealing with which I call "$Cx distortion squared" ... :)  three different cases, each one with two note tables.  I haven't documented the third case yet, but I do have note tables, so the next step is demo tunes.

 

In short, you get the same notes as in $Cx (both rough bass, and smooth mod 3 bass), but with additional modulation from the first channel ... which can be done in a mod 5, mod 3, or non mod fashion.

 

Attaching a frequency table here.

 

Also:  AUDF1=11 and AUDF2=14 generates silence for note rests :)

 

 

AUDCTL=$40 SKCTL=$8B AUDC1=$4x AUDC2=$00.txt

Edited by Synthpopalooza
Link to comment
Share on other sites

OK, demo complete.  This is a rendition of the Stickerbrush Symphony from Donkey Kong Country 2

 

Settings used:

 

AUDCTL=$60 (1.79 mhz clock on 0 and 1)

SKCTLS=$8B (Two tone modulation on 0 and 1)

 

0 - $4x (1.79 mhz, modulation)

1 - Silent (frequency carrier for 0)

2 - $Ax (standard square wave)

3 - $Cx (1.79 mhz, sawtooth wave, high lead)

 

So, a host of explanations are in order ...

 

When you set two-tone modulation on 0 and 1, with 0 as the $4x distortion, it creates a similar note table as $Cx ... you get a number of frequency tables, a couple of them are based on a mod 3 table, and a non mod 3 table, like in standard $Cx basses.

 

When using mod3, you choose frequencies where (freq+4) mod 3 = 0.  This makes for smooth bass tones.  If you choose (freq+4) mod3 <>0 and <>5, rough bass tones are had.  This is exactly like $Cx, but with different note tables.   These are played on channel 1, the frequency carrier, which is always silenced.

 

Now in channel 0, we do modulations.  For mod 3 bass tones, we always do our modulations based on (mod+4) mod 5 = 0.  This takes the frequency, and adds a bitwise modulation to it.  Certain settings will morph the tone into a vibrato electric guitar.  On settings where (mod+4) mod 5 =0 and (Mod+4) mod 3=0, you get the standard frequencies, but the higher you go in these, the fuzzier they sound ... which can be a desirable effect, like putting them through a fuzzbox that adds a slight distortion to the tones.

 

The tune starts out with an electric guitar in the bass hit, then when the sequenced bass kicks in, it cycles through various modulations on the same note.

 

I am attaching a rough note table, it is by no means complete, but is a very good beginning!

 

Emulation notes:

 

Prosystem and A7800, as expected, cannot do the two tone modulation correctly.  In addition, Prosystem will play the $Cx channel correctly, but A7800 drops notes in that channel.

 

Recording attached from Altirra emulator, which does this as it should sound on real hardware.

 

Again, a test on real hardware will tell the true tale. :) 

 

 

 

 

 

 

dkc-stickerbrush.A78 dkc-stickerbrush.asm dkc-stickerbrush.bin dkc-stickerbrush-450.A78 dkc-stickerbrush-450.asm dkc-stickerbrush-450.bin dkc-stickerbrush.wav

  • Like 5
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...