analmux Posted November 21, 2007 Share Posted November 21, 2007 (edited) Well, it's been a while since I was last active on this site, but I didn't throw away my atari Last time I've done some fooling around with Pokey and especially tried to gain more insight in how it generates sound. To start at the end: I've found a way to reset the polycounters. What is a Polycounter? For those who don't know: It's a kind of digital counting circuit (inside of Pokey) that generates series of bit patterns. Polycounters are used for a number of things: -generating random numbers (to be read from $D20A) -generating sound, especially the non typically squarewave sounds like: ...-drones (combined 4&5 bit polycounter or distortion 4) ...-pink/white e.a. noise (17 or combined 17%5 bit polycounter: distortion 8 or 0) ...-bass notes (4bit polycounter distortion 12) ...-other sound (5bit polycounter distortion 2) Especially the last thing: bass notes, are used a lot in Pokey tunes. Most trackers support notation tables for distortion 12 (or c) bass. Most Pokey musicians should know that some of the bass notes (pitches) are unstable (especially when Pitch+1 is an integer multiple of 3 or 5). With this I mean, some times the sound's timbre is different than other times. This is caused by a synchronization problem. 1) Bass notes are generated by distortion 12, which is generated by the output of a 4bit polycounter 2) A 4bit polycounter has 15 (=2^4 -1) distinct steps: After that it starts repeating itself. 3) All polycounters run at a speed of 1.79MHz. They are sampled by the divide-by-N counter belonging to a channel (AUDF speed) Note: -The (unique) prime factorization of 15 is 3 * 5 -The (unique) prime factorization of 28 is 2 * 2 * 7 -The (unique) prime factorization of 114 is 2 * 3 * 19 So 15 and 114 are not relatively prime i.e. share a common prime factor But 15 and 28 are relatively prime. Now, Pokey has two global clockings for its channels: -64kHz which corresponds to 28 clockcycles per divide-by-N cycle ...so, the REAL pitch is P = 28 * (Pitch +1) 15kHz which corresponds to 114 clockcyles per divide-by-N cycle (note: this is exactly the duration of a scanline!) ...so, the REAL pitch is P = 114 * (Pitch +1) So in 64 kHz mode, because 28 and 15 are relatively prime, there are two types of instability/degeneracy: Type 3: when Pitch+1 = multiple of 3 Type 5: when Pitch+1 = multiple of 5 When Pitch is not of type 3 or type 5, then the sound is perfectly stable. Note, that in 15kHz mode every divide-by-N cycle is 114 clockcycles. Because 15 and 114 have a common prime factor (which is 3), the sound is automatically degenerate of type 3. Only the notes with Pitch+1 = a multiple of 5 have the type-5-degeneracy. So in 15khz mode there are NO stable pitches, so distortion 12 basses sound worse in 15kHz mode than in 64kHz mode. Also note that you can f.e. use a 5bit polycounter in 1.79MHz mode (distortion 2), but 2^5-1 =31. The bit-sequence has 31 steps. Now 31 is a prime number, so then there are no degerate/unstable sounds. Now, RMT uses two different bass tables. It's RMT-distortion C and E (both Pokey-distortion 12). -Table E uses pitches such that Pitch+1 is not a multiple of 3 -Table C uses pitches such that Pitch+1 is a multiple of 3 So, in fact there's no problem when using table E basses. But table E basses sound more 'industrial' while table C basses sound more deeply. But, table C basses are unstable. It's exactly the timbre-type that makes us want to use pitches which are degenerate. So, for distortion-12-bass, we have a problem synchronizing the used polycounter with a (channel-related) divide-by-N counter. But, look here: http://www.atariage.com/forums/index.php?showtopic=47235 Jaskier wrote the following there: April the 1st. You cannot freeze random generator. But, in fact you can (Bryan seconds that ). It's a thing I once found out, when I did Poke 39973,208 (in atari basic) to watch the chip registers. Then I poked a zero to 53775 ($D20F) which is the SKCTL register of Pokey. Normally you'd see the random registers flashing, but then it stopped. So, some months ago I tried to do it again and realized that this might be an indication that this procedure actually stops all polycounters. Then put a 3 back in SKCTL (Default value of SKCTL is 3 (find it in $0232 = SSKCTL)) and the polycounters start again. The great thing is now that it starts again at the start of its bit sequence. Or again in other words: This procedure RESETS all polycounters. So for example, do this in Basic: Sound 0,200,4,10 which gives a drone sound, but it is one of the degenerate ones. then type Poke 53775,0:poke 53775,3 and apply this as many times as you like. (Almost) every time you'll hear the sound type changing. Not exactly always, because there's an external (relative) timing uncertainty (caused by pushing the keys on your keyboard). You can repeat this f.e. when doing some other sound, let's say a bass-note: Sound 0,98,12,10. To come to a conclusion: It is in fact possible to have a full control over the timbre when using some short reset routine (in Machine Language). So, when using this in f.e. a Pokey tracker, it is finally possible to have stable bass-notes. IMPORTANT NOTE: This all won't work in emulation, only on the real thing. Edited November 21, 2007 by Analogue Multiplexer Quote Link to comment Share on other sites More sharing options...
vitaflo Posted November 21, 2007 Share Posted November 21, 2007 This is pretty sweet, but I have two questions. Note, that in 15kHz mode every divide-by-N cycle is 114 clockcycles. Because 15 and 28 have a common prime factor (which is 3), the sound is automatically degenerate of type 3. Wouldn't that be 15 and 114 have a common prime factor of 3? I'm assuming this is a typo otherwise I'm pretty confused. Also note that you can f.e. use a 5bit polycounter in 1.79MHz mode (distortion 2), but 2^5-1 =31. The bit-sequence has 31 steps. Now 31 is a prime number, so then there are no degerate/unstable sounds. Is this true? Why wouldn't Pitch+1 at multiples of 31 also be unstable? Pretty damn good write up though I'll say that. Gonna play with this when I get home. Quote Link to comment Share on other sites More sharing options...
analmux Posted November 21, 2007 Author Share Posted November 21, 2007 (edited) Wouldn't that be 15 and 114 have a common prime factor of 3? I'm assuming this is a typo otherwise I'm pretty confused. Oops, yes you're right. Gonna edit it out immediately Why wouldn't Pitch+1 at multiples of 31 also be unstable? That's sharply observed. You're right. 31 should also give instability. In fact this applies to all polycounter distortions off course. Though, when using 5bit polycounter (dist. 2) on a 1.79mhz voice, when Pitch+1 = a multiple of 31 then the frequency of the output sound lies 31 times higher as 'should be'. That lies far above the audible spectrum. That's one of the reasons you'd not use those pitchvalues. In the strict sense those pitches (for 5bit poly) also don't give a stable sound. Sometimes they're even just silent. It depends on the bitpatterns. When a 0 is sampled it will remain silent. When a 1 is sampled it will generate a squarewave type sound. So indeed there are 3 types of degeneracy for the 4bit polycounter: -type 3 -type 5 -type 15 and for 5bit polycounter there's only one: -type 31 when 17bit poly is truncated to 9bit (set bit7 of Audctl), then the bit-sequence is 2^9-1 = 511 bytes long. This is also non-prime. That's why there's: -type 7 -type 73 -type 511 the consequences of this can best be heard when clocking in 1.79mhz: (set bit7 and 6 of audctl) Then: if Pitch+4 is a multiple of 7 or 73 you get different sounds (also with a different notation) Notice: in 64kHz all REAL pitches P=28 * (Pitch +1) are multiples of 7, so are at least of type 7 degeneracy, i.e. there are no non-degenerate pitches then. Edited November 21, 2007 by Analogue Multiplexer Quote Link to comment Share on other sites More sharing options...
analmux Posted November 21, 2007 Author Share Posted November 21, 2007 The following is also weird : Try to type this in Basic POKE 53760,3*61-1 FOR Z=0 TO 99999:POKE 53761,196:FOR T=0 TO 29:NEXT T:POKE 53761,0:FOR T=0 TO 11:NEXT T:NEXT Z It could be used as a bass line for some electronic style track All it does is changing the relative timing between the Polycounter and the Divide-by-N counter. Quote Link to comment Share on other sites More sharing options...
vitaflo Posted November 21, 2007 Share Posted November 21, 2007 (edited) That's sharply observed. You're right. 31 should also give instability. In fact this applies to all polycounter distortions off course. In the strict sense those pitches (for 5bit poly) also don't give a stable sound. Sometimes they're even just silent. It depends on the bitpatterns. When a 0 is sampled it will remain silent. When a 1 is sampled it will generate a squarewave type sound. Now that I'm able to test this, I'm seeing this is true. If you do: SOUND 0,248,2,10 This is a multiple of 31. You may get nothing, or you may get a pure tone. If you poke into 53775 as you show above a couple times you'll be able to flip back and forth between silence or a tone. What's interesting is the tone isn't distorted even though it's 5-bit poly. The same seems true for 4-bit poly's with Pitch+1 at multiples of 15. If you do: SOUND 0,179,12,10 You either get nothing, or a pop. Poking 53775 again will flip between these two. Also interesting that it's just a pop. This is very cool stuff, and makes Pokey make a lot more sense of why it sounds certain ways. Edited November 21, 2007 by vitaflo Quote Link to comment Share on other sites More sharing options...
Allas Posted November 21, 2007 Share Posted November 21, 2007 This is intentionally to avoid a future deleted message. Well, it's been a while since I was last active on this site, but I didn't throw away my atari Last time I've done some fooling around with Pokey and especially tried to gain more insight in how it generates sound. To start at the end: I've found a way to reset the polycounters. What is a Polycounter? For those who don't know: It's a kind of digital counting circuit (inside of Pokey) that generates series of bit patterns. Polycounters are used for a number of things: -generating random numbers (to be read from $D20A) -generating sound, especially the non typically squarewave sounds like: ...-drones (combined 4&5 bit polycounter or distortion 4) ...-pink/white e.a. noise (17 or combined 17%5 bit polycounter: distortion 8 or 0) ...-bass notes (4bit polycounter distortion 12) ...-other sound (5bit polycounter distortion 2) Especially the last thing: bass notes, are used a lot in Pokey tunes. Most trackers support notation tables for distortion 12 (or c) bass. Most Pokey musicians should know that some of the bass notes (pitches) are unstable (especially when Pitch+1 is an integer multiple of 3 or 5). With this I mean, some times the sound's timbre is different than other times. This is caused by a synchronization problem. 1) Bass notes are generated by distortion 12, which is generated by the output of a 4bit polycounter 2) A 4bit polycounter has 15 (=2^4 -1) distinct steps: After that it starts repeating itself. 3) All polycounters run at a speed of 1.79MHz. They are sampled by the divide-by-N counter belonging to a channel (AUDF speed) Note: -The (unique) prime factorization of 15 is 3 * 5 -The (unique) prime factorization of 28 is 2 * 2 * 7 -The (unique) prime factorization of 114 is 2 * 3 * 19 So 15 and 114 are not relatively prime i.e. share a common prime factor But 15 and 28 are relatively prime. Now, Pokey has two global clockings for its channels: -64kHz which corresponds to 28 clockcycles per divide-by-N cycle ...so, the REAL pitch is P = 28 * (Pitch +1) 15kHz which corresponds to 114 clockcyles per divide-by-N cycle (note: this is exactly the duration of a scanline!) ...so, the REAL pitch is P = 114 * (Pitch +1) So in 64 kHz mode, because 28 and 15 are relatively prime, there are two types of instability/degeneracy: Type 3: when Pitch+1 = multiple of 3 Type 5: when Pitch+1 = multiple of 5 When Pitch is not of type 3 or type 5, then the sound is perfectly stable. Note, that in 15kHz mode every divide-by-N cycle is 114 clockcycles. Because 15 and 114 have a common prime factor (which is 3), the sound is automatically degenerate of type 3. Only the notes with Pitch+1 = a multiple of 5 have the type-5-degeneracy. So in 15khz mode there are NO stable pitches, so distortion 12 basses sound worse in 15kHz mode than in 64kHz mode. Also note that you can f.e. use a 5bit polycounter in 1.79MHz mode (distortion 2), but 2^5-1 =31. The bit-sequence has 31 steps. Now 31 is a prime number, so then there are no degerate/unstable sounds. Now, RMT uses two different bass tables. It's RMT-distortion C and E (both Pokey-distortion 12). -Table E uses pitches such that Pitch+1 is not a multiple of 3 -Table C uses pitches such that Pitch+1 is a multiple of 3 So, in fact there's no problem when using table E basses. But table E basses sound more 'industrial' while table C basses sound more deeply. But, table C basses are unstable. It's exactly the timbre-type that makes us want to use pitches which are degenerate. So, for distortion-12-bass, we have a problem synchronizing the used polycounter with a (channel-related) divide-by-N counter. But, look here: http://www.atariage.com/forums/index.php?showtopic=47235 Jaskier wrote the following there: April the 1st. You cannot freeze random generator. But, in fact you can (Bryan seconds that ). It's a thing I once found out, when I did Poke 39973,208 (in atari basic) to watch the chip registers. Then I poked a zero to 53775 ($D20F) which is the SKCTL register of Pokey. Normally you'd see the random registers flashing, but then it stopped. So, some months ago I tried to do it again and realized that this might be an indication that this procedure actually stops all polycounters. Then put a 3 back in SKCTL (Default value of SKCTL is 3 (find it in $0232 = SSKCTL)) and the polycounters start again. The great thing is now that it starts again at the start of its bit sequence. Or again in other words: This procedure RESETS all polycounters. So for example, do this in Basic: Sound 0,200,4,10 which gives a drone sound, but it is one of the degenerate ones. then type Poke 53775,0:poke 53775,3 and apply this as many times as you like. (Almost) every time you'll hear the sound type changing. Not exactly always, because there's an external (relative) timing uncertainty (caused by pushing the keys on your keyboard). You can repeat this f.e. when doing some other sound, let's say a bass-note: Sound 0,98,12,10. To come to a conclusion: It is in fact possible to have a full control over the timbre when using some short reset routine (in Machine Language). So, when using this in f.e. a Pokey tracker, it is finally possible to have stable bass-notes. IMPORTANT NOTE: This all won't work in emulation, only on the real thing. Quote Link to comment Share on other sites More sharing options...
Rybags Posted November 22, 2007 Share Posted November 22, 2007 Interesting. So, does resetting the counters absolutely ensure consistent sound? Even in Assembler there's the problem of uncertain timing due to DMA. I guess a sound routine could always employ creative use of WSYNC to ensure consistency. Also, we have STIMER which can be used to reset the AUDFn registers to a known state - can this also be useful in conjunction with the other method? Quote Link to comment Share on other sites More sharing options...
raster/c.p.u. Posted November 22, 2007 Share Posted November 22, 2007 Thanks for interesting exploration. To come to a conclusion:It is in fact possible to have a full control over the timbre when using some short reset routine (in Machine Language). So, when using this in f.e. a Pokey tracker, it is finally possible to have stable bass-notes. Ok, stable bass-notes, it is what interest me. IMPORTANT NOTE: This all won't work in emulation, only on the real thing. Unfortunately, (as I told to Emkay a long time ago), I'm not able to correct this in pokey emulation. Quote Link to comment Share on other sites More sharing options...
analmux Posted November 22, 2007 Author Share Posted November 22, 2007 (edited) ...If you do:SOUND 0,248,2,10 This is a multiple of 31.... You may get nothing, or you may get a pure tone. If you poke into 53775 as you show above a couple times you'll be able to flip back and forth between silence or a tone. What's interesting is the tone isn't distorted even though it's 5-bit poly. I think it should be Sound 0,247,2,10 in this case (forgot the -1 ? ). Indeed, the idea is that when poly5 is a 31-step polycounter, all pitches that are an integer multiple of 31 result in squarewaves. The same happens with the poly4: A) All pitches (Pitch+1) that are not a multiple of 3,5 or 15 give maximal distortion --> sample table is 15-step B) Pitches that are a multiple of 3 (but not of 5 or 15) give less distortion than type A --> sample table is 5-step ...there is though a 3-fold degeneracy caused by the uncertainty in timing C) Pitches that are a multiple of 5 (but not of 3 or 15) give again less distortion than type B --> sample table is 3-step ...again degeneracy, be it 5-fold. D) Pitches that are a multiple of 15 --> sample table is just one-step: no distortion at all (but it is also silent. in case of poly5 this would give a pure squarewave tone) Only difference is between poly4 and poly5: they are connected slightly different inside pokey. That's why: -in poly4: always a silence (or a pop) when (Pitch+1)/15 is an integer. -in poly5: sometimes a pure (squarewave) tone when (Pitch+1)/31 is integer. The distortion I still don't fully understand is 4: combined poly4 & poly5 Edited November 22, 2007 by Analogue Multiplexer Quote Link to comment Share on other sites More sharing options...
analmux Posted November 22, 2007 Author Share Posted November 22, 2007 Thanks for interesting exploration.To come to a conclusion:It is in fact possible to have a full control over the timbre when using some short reset routine (in Machine Language). So, when using this in f.e. a Pokey tracker, it is finally possible to have stable bass-notes. Ok, stable bass-notes, it is what interest me. IMPORTANT NOTE: This all won't work in emulation, only on the real thing. Unfortunately, (as I told to Emkay a long time ago), I'm not able to correct this in pokey emulation. It's also a pity that I'm not good at coding a new Pokey.dll or something....but TMC is an atari tool when I'm correct. Jaskier should be surprised when he reads this. But, it should be possible to implement it anyway in RMT. The correct result should then be heard when you play your compiled/exported RMT song on a real Atari. Quote Link to comment Share on other sites More sharing options...
analmux Posted November 22, 2007 Author Share Posted November 22, 2007 (edited) ... Edited January 2, 2008 by Analogue Multiplexer Quote Link to comment Share on other sites More sharing options...
analmux Posted November 22, 2007 Author Share Posted November 22, 2007 (edited) So, does resetting the counters absolutely ensure consistent sound? Yes, I've tested a few routines. First routine was based on a waiting loop. Last routine just does 6 operations to pokeyregisters, without any waiting loops. The important things is to do those 6 in the right order. Accuracy is 100% Even in Assembler there's the problem of uncertain timing due to DMA. Yes, I've noticed indeed. So, when I started experimenting I first made sure that the reset routine is always executed in a non-display area (f.e. scanline 0 to 31). I'm not sure what PM DMA does with this, but it can be disabled before executing the reset code. When you've fixed the DMA timing behind the routine, then it's 100% accurate. I guess a sound routine could always employ creative use of WSYNC to ensure consistency. Yes, that's indeed the point. Thus, always make sure that the underlying DMA scheme is always the same. Also, we have STIMER which can be used to reset the AUDFn registers to a known state - can this also be useful in conjunction with the other method? Yep, That's the whole trick. So in fact, when you've selected a fixed timing for executing the reset code, all you have to do next is something like this: lda #0 ldx #3 sta skctl ($D20F) sta wsync ($D40A) lda #(polycounter or filter offset number) ldy #(pitch number) sta audf1 ($D200) sta stimer ($D209) sty audf1 ($D200) stx skctl ($D20F) (I'd have to look this up, can't remember exactly my last experiment anymore) Notes: 1) this is only needed once (thus not every PAL/NTSC frame), when you start a note. 2) the reset routine disturbs all timings: filter settings will be reset also 3) similar tricks can be used to gain 100% perfect filter settings and flanger-settings Edited January 2, 2008 by Analogue Multiplexer Quote Link to comment Share on other sites More sharing options...
Rybags Posted November 22, 2007 Share Posted November 22, 2007 Don't worry so much about PMG DMA. RAM refresh DMA is the uncertainty. There's a thread from some time back which has diagrams showing where it occurs. But, for consistency, I think using WSYNC more or less assures the same conditions (although that might not apply in widescreen mode or with HScrolling turned on). Is the source for POKEY emulation available? It might be reasonably simple to alter it to properly simulate POKEY being put into the INIT state. What is it that you don't understand about AUDC mode 4? Maybe something tricky goes on there, like EORing them together or something. Quote Link to comment Share on other sites More sharing options...
analmux Posted November 22, 2007 Author Share Posted November 22, 2007 @ Rybags As far as I know, the DRAM refresh DMA always occurs at the same timing (9 cycles at the left part of the screen, or 1 cycle when a badline occurs), so that's not my worry. I'm more worried about situations with different DMA schemes. F.e. when a pokey tune is playing, and suddenly (f.e. in a game engine) PM is activated, then there's an inconsistency, but maybe it won't matter that much. Would have to check that ...PM eats another 5 cycles when activated. I've done an experiment by myself 4 years back, connecting (by copper wire) the CPU-halt pin with one of the lum-pins of GTIA: then you see exactly where DRAM refresh happens. Distortion 4 is especially fuzzy when just normal standard 64kHz clocking is used. Using 1.79MHz gives nicer sounds, especially 16bit distortion 4. Same applies to distortion 8 (with poly9 instead of poly17). As far as I know (and can see) there's indeed a logical operation between poly5 and poly4/17. Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted November 22, 2007 Share Posted November 22, 2007 Is the source for POKEY emulation available? It might be reasonably simple to alter it to properly simulate POKEY being put into the INIT state. These were the last ones I would think: http://www.atariage.com/forums/index.php?showtopic=75505 I don't recall these replacing those on the RMT site either. The last discusions I know of where on the Atari800 developer list: http://sourceforge.net/mailarchive/message...7020009%40op.pl From the people discussing this, Piotr Fusik (Fox) contributes here too, Michael Borisov - the main(?) author of the currently used routine but I'm not sure if still active, Kostas Nakos - may have been taking over development? and Perry McFarlane who appears busy on making improvements to the emulator. If any of those can provide this board with an update of their plans for the Pokey emulation then that might prove useful. Conversely, contributing not necessarily with code but ideas to the team would be good too. Regards, Mark Quote Link to comment Share on other sites More sharing options...
analmux Posted November 22, 2007 Author Share Posted November 22, 2007 I've noticed that the current emulation doesn't support the SKCTL ($d20f) register 100% anyway on the real machine: poke 53775,0 should result in a lockup (keyboard shut down) in emulation this isn't happening. Quote Link to comment Share on other sites More sharing options...
Rybags Posted November 22, 2007 Share Posted November 22, 2007 To confuse things even more, you have DList DMA to consider as well. It normally occurs after the PMGs have been done, although if PM DMA isn't enabled, ANTIC will take the opportunity to do it early. But, I guess that again by resorting to WSYNC you might avoid such dramas. Re SKCTL - I guess it isn't really all that relevant for 100% emulation since the key handling is a bit of a kludge anyway, as is SIO and pot inputs. Suppose if someone does goto the trouble of improving the emulation of POKEY, it would also be nice to have the timers working properly (ie cycle exact). Nice trick with the Halt to Lum connection... I think you can get that effect too if you use RF and don't tune the channel properly. Quote Link to comment Share on other sites More sharing options...
raster/c.p.u. Posted November 23, 2007 Share Posted November 23, 2007 (edited) lda #0 ldx #3 sta skctl ($D20F) sta wsync ($D40A) lda #(polycounter or filter offset number) ldy #(pitch number) sta audf1 ($D200) sta stimer ($D209) sty audf1 ($D200) stx skctl ($D20F) (I'd have to look this up, can't remember exactly my last experiment anymore) Watch page III.17 of Hardware_part2.pdf: There's given a hint about it. (anyway, thanks Rybags for making them available ) See footnote **: "...pokey has no reset pin..." --> should be done by software --> polycounters can be reset. Notes: 1) this is only needed once (thus not every PAL/NTSC frame), when you start a note. 2) the reset routine disturbs all timings: filter settings will be reset also 3) similar tricks can be used to gain 100% perfect filter settings and flanger-settings I was testing it yesterday and I haven't found usable method for polycounters reseting. As you said in (1) and (2), reset of polycounters disturbs all timings - and it's a problem. In RMT player routine there is something like this for setting of pokey registers: ldy #$ff v_audctl2 equ *-1 lda trackn_audf+0+4 ldx trackn_audf+0 sta $d210 stx $d200 lda trackn_audc+0+4 ldx trackn_audc+0 sta $d211 stx $d201 lda trackn_audf+1+4 ldx trackn_audf+1 sta $d212 stx $d202 lda trackn_audc+1+4 ldx trackn_audc+1 sta $d213 stx $d203 lda trackn_audf+2+4 ldx trackn_audf+2 sta $d214 stx $d204 lda trackn_audc+2+4 ldx trackn_audc+2 sta $d215 stx $d205 lda trackn_audf+3+4 ldx trackn_audf+3 sta $d216 stx $d206 lda trackn_audc+3+4 ldx trackn_audc+3 sta $d217 stx $d207 lda #$ff v_audctl equ *-1 sty $d218 sta $d208 Thanks to instruments' envelopes, AUD-F/C/CTL registers are changing many times during each note, also notes can be changing in very fast tempo, so there is not possible to do something "only when you start a note". (In addition, instrument speed can be up to 4 times per frame!) So, I don't know, how it could be managed. If you know, please let me know. Edited November 23, 2007 by raster/c.p.u. Quote Link to comment Share on other sites More sharing options...
Rybags Posted November 23, 2007 Share Posted November 23, 2007 One thing I've just noticed in the debugger: Resetting with SKCTL might not be totally necessary. I've tried playing a note (AUDC=C8, AUDF=A9) Every once in a while, nothing happens. But, simply changing AUDF to another value and back again "resets" and you're back to the same "random" chance of the note playing or not. Of course, you should really change AUDC as well to prevent unwanted notes. Maybe there is some timing issue here - might have to do some experimentation. If trying to play one of these "dodgy" frequencies, maybe there is some constant time delay which will ensure that the note always plays (or not). Quote Link to comment Share on other sites More sharing options...
Clint Thompson Posted November 23, 2007 Share Posted November 23, 2007 Nice read! I did the bass line thing btw and it was.... eh... meh... but it has potential. Quote Link to comment Share on other sites More sharing options...
analmux Posted November 24, 2007 Author Share Posted November 24, 2007 I was testing it yesterday and I haven't found usable method for polycounters reseting. But what did you do exactly then? How did you call the subroutine? Did you activate it on a scanline where gfx is displayed? As you said in (1) and (2), reset of polycounters disturbs all timings - and it's a problem. In RMT player routine there is something like this for setting of pokey registers:... Thanks to instruments' envelopes, AUD-F/C/CTL registers are changing many times during each note, also notes can be changing in very fast tempo, so there is not possible to do something "only when you start a note". (In addition, instrument speed can be up to 4 times per frame!) So, I don't know, how it could be managed. If you know, please let me know. I don't see a real big problem here. 1) The poly4 is mainly used for bass notes 2) It's rather rare to have f.e. arpeggio, portamento or vibrato on bass notes. 3) When you actually try to do portamento on bass notes you'd get crazy results anyway, since the notation table for basses has too low resolution. 4) Volume changes don't make any difference (except from 0 to 1-15 or vice versa, when I'm correct) so ADSR is still possible 5) When poly4 and div-by-N are synced correctly, then you'll always be able to know how they will be synced after a pitch-change, or in other words, you can always compute how the timing will change. 6) When playing a bass note, I suppose you'll keep distortion number always the same. Main problem is that you don't know a priori how poly4 and div-by-N are synced in the first place. Once you know, you can control everything. It's the same idea as syncing f.e. div-by-N counters of voice 1 & 3 that are used for filtering (pulsewaves). You only need to write once at the start of the note a value to $D209 to assure that they are in sync. Then you can control pulsewidth variation very easily after that, because you know how the filter settings at a certain moment already are. But, in case you want to do other weird stuff with polycounter distortions (f.e. 1.79mhz clocked & filtered settings) then there's indeed a restriction. Quote Link to comment Share on other sites More sharing options...
analmux Posted November 24, 2007 Author Share Posted November 24, 2007 Resetting with SKCTL might not be totally necessary. I've tried playing a note (AUDC=C8, AUDF=A9) Every once in a while, nothing happens. But, simply changing AUDF to another value and back again "resets" and you're back to the same "random" chance of the note playing or not. Exactly, but you have indeed no full control of the wanted timing. It's indeed a change in timing, but you don't know which timing. Of course, you should really change AUDC as well to prevent unwanted notes. Maybe there is some timing issue here - might have to do some experimentation. If trying to play one of these "dodgy" frequencies, maybe there is some constant time delay which will ensure that the note always plays (or not). This is a part I totally don't understand Quote Link to comment Share on other sites More sharing options...
perry_m Posted November 25, 2007 Share Posted November 25, 2007 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. Quote Link to comment Share on other sites More sharing options...
Bryan Posted November 25, 2007 Share Posted November 25, 2007 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. Quote Link to comment Share on other sites More sharing options...
Clint Thompson Posted November 26, 2007 Share Posted November 26, 2007 Would be interesting to punch in Bryan if your willing to share and it's not too much to post.... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.