vdub_bobby Posted April 29, 2008 Share Posted April 29, 2008 I've spent the last day or so searching the forums with not much to show for it except tantalizing hints - so I'll explicitly request here: can someone tell me, specifically, how to get sawtooth/triangle wave sounds with POKEY? And any other fanciness? I did find this explanation for how to, I believe, vary the duty cycle of the square waves using the 2-tone filter. I'm looking for stuff that is possible by banging the registers once - or maybe twice - a frame. Code examples would make me weep for joy, either in Basic or assembly. Thanks! Quote Link to comment Share on other sites More sharing options...
analmux Posted April 29, 2008 Share Posted April 29, 2008 (edited) Hmmm, it's a nice point here to explain a few things sawtooth wave: 1 P=53760 2 POKE P+8,64+32+4 3 POKE P+1,166 4 POKE P,F:POKE P+4,F+1 5 STOP ((line 5 edited in later )) Line 2: Here P+8 is the AUDCTL register. I set bits 6,5 and 2: 6: put channel 1 clocking to 1.79MHz 5: put channel 3 clocking to 1.79MHz 2: activate 'high-pass filter' Line 3: channel 3 is silent. channel 1 is on: distortion 10 at volume 6 Line 4: set frequencies. Line 5: to make sure basic doesn't switch off pokey voices after termination of the program The value of F is computed like this: If PHI=1789790/wanted frequency, then F is computed like: F= (SQR(1+4*PHI)-9)/2 This relation holds also for the triangle wave, but the resulting note is exactly one octave lower. For the triangle wave you do: 1 P=53760 2 POKE P+8,64+32 3 POKE P+1,175:POKE P+5,175 4 POKE P,F:POKE P+4,F+1 This is just one of the methods to generate these waveforms. Key comment is though that you shouldn't want these waveforms for low/bass notes. This is not possible on Pokey. Other method would be to do: 4 POKE P,F:POKE P+4,F+N then the formula for F is different. For N>1 the formulas of triangle and sawtooth will differ a lot though. But, when using variable N allows us to get much finer control of the wanted frequency. The following is a nice 1st order notation table for sawtooth (& triangle). The table tells you which F you need for a desired semi-tone. $71,$6e,$6b,$68,$65,$62,$5f,$5c,$59,$56,$54,$51,$4f,$4d,$4a,$48 $46,$44,$42,$40,$3e,$3c,$3a,$38,$36,$35,$33,$32,$30,$2f,$2d,$2c $2a,$29,$28,$26,$25,$24,$23,$22,$21,$20,$1f,$1e,$1d,$1c,$1b,$1a $19,$18,$17,$17,$16,$15,$14,$14,$13,$12,$12,$11,$10,$10,$0f,$0f I used this table in the RMT-hack I did to support sawtooth. Edited April 30, 2008 by Analogue Multiplexer Quote Link to comment Share on other sites More sharing options...
analmux Posted April 29, 2008 Share Posted April 29, 2008 (edited) ....(supplement: note: if you won't hear sounds as expected, you must do a POKE 53775,3 to ensure that all pokeychannels are active) About the 2-tone filter: It's the easiest way to obtain a stable pulse type wave. The only drawback is that you cannot use all desired duty-cycle widths. The only way to do that is by the standard 'high-pass-filter'. Then the only way to get reliable sound is using M.L. audf1=$d200 audc1=$d201 audf3=$d204 audctl=$d208 stimer=$d209 skctl=$d20f lda #3 sta skctl lda #5 sta audctl lda #166 sta audc1 ldx #(X1) lda #(X2) sta audf3 stx audf1 stx stimer sta audf1 When X2 is the wanted frequency (it is a measure of the time-interval between phase-transitions of the pulsewave) and D is the duty-cycle-width, then X1 is needed to do the proper filter-offset: X1 = INT(D*X2). Beware: D should be a number between 0 and 1. When the 'filter' offset has been done, it is fixed. You can now modulate the duty-width by varying (X2) a little bit, and writing X2 only to AUDF1. The write to STIMER should only be done once. Edited April 29, 2008 by Analogue Multiplexer Quote Link to comment Share on other sites More sharing options...
vdub_bobby Posted April 30, 2008 Author Share Posted April 30, 2008 Thanks; I'll play around with some of this stuff. Does any of this work in emulation or is it all real hardware only? Quote Link to comment Share on other sites More sharing options...
analmux Posted April 30, 2008 Share Posted April 30, 2008 Does any of this work in emulation or is it all real hardware only? The best is to try it on a real Atari 8bit. Sawtooth is supported by the latest emulators. Triangle not. And a.f.a.i.k. there are some minor timing issues, such that the pulsewave/filter-offset isn't supported for 100% (in terms of accuracy). Quote Link to comment Share on other sites More sharing options...
vdub_bobby Posted April 30, 2008 Author Share Posted April 30, 2008 Does any of this work in emulation or is it all real hardware only? The best is to try it on a real Atari 8bit. Sawtooth is supported by the latest emulators. Hm. I typed that sawtooth code in AtariWin800 4.0 and got nothing - no sound, no nothing. Quote Link to comment Share on other sites More sharing options...
analmux Posted April 30, 2008 Share Posted April 30, 2008 I have Atari8win 4.0 beta 7 running. Don't forget to define F first, or type a value instead of F. F.e. POKE P,43:POKE P+4,44 should give some results. Quote Link to comment Share on other sites More sharing options...
vdub_bobby Posted April 30, 2008 Author Share Posted April 30, 2008 (edited) Just downloaded beta 7; still doesn't work. If I have time tonight I'll try on my 130XE. EDIT: I got it to work by typing in the POKEs directly...wouldn't work when I ran the program. I'm very rusty on my BASIC, maybe I did something wrong? Anyway, sounds cool; thanks! Edited April 30, 2008 by vdub_bobby Quote Link to comment Share on other sites More sharing options...
analmux Posted April 30, 2008 Share Posted April 30, 2008 (edited) Ah, of course. How silly of me When a program ends, basic turns off all sound. (I editted post 2 in the meantime ) Edited April 30, 2008 by Analogue Multiplexer Quote Link to comment Share on other sites More sharing options...
vdub_bobby Posted May 22, 2008 Author Share Posted May 22, 2008 then the formula for F is different. For N>1 the formulas of triangle and sawtooth will differ a lot though. But, when using variable N allows us to get much finer control of the wanted frequency. What are the formulas for N>1? Quote Link to comment Share on other sites More sharing options...
Oswald Posted May 22, 2008 Share Posted May 22, 2008 This is just one of the methods to generate these waveforms. Key comment is though that you shouldn't want these waveforms for low/bass notes. This is not possible on Pokey. hmm havent you said in the flame thread that pokey can do anything the sid can ? gotcha Quote Link to comment Share on other sites More sharing options...
vdub_bobby Posted May 22, 2008 Author Share Posted May 22, 2008 (edited) This is just one of the methods to generate these waveforms. Key comment is though that you shouldn't want these waveforms for low/bass notes. This is not possible on Pokey. hmm havent you said in the flame thread that pokey can do anything the sid can ? gotcha Holy crap, man, take your stupid comments to PM and stop clogging up every damn thread with off-topic nonsense. EDIT: http://www.atariage.com/forums/index.php?act=boardrules 3) Using the forum to excessively promote your "agenda". For example, if love or hate a certain game console, that is fine. But if you feel the need to interject your love or hatred into various topics any chance you get, and it is disrupting the forum, we consider this spamming. This is also considered Trolling (see below). Trolling Trolling isn't always easy to define, but it generally is easy to spot. Trolling usually involves disrupting a thread by posting messages that are off-topic, rude, inciting, and so forth. We recognize that topics will often veer off course for one reason or another, but when an individual member repeatedly disrupts threads in a negative fashion, that member will be warned. Trolling also includes creating new threads for the purpose of starting flame wars (known as "flamebait"). Edited May 22, 2008 by vdub_bobby Quote Link to comment Share on other sites More sharing options...
analmux Posted May 22, 2008 Share Posted May 22, 2008 This is just one of the methods to generate these waveforms. Key comment is though that you shouldn't want these waveforms for low/bass notes. This is not possible on Pokey. hmm havent you said in the flame thread that pokey can do anything the sid can ? gotcha I don't know of a flame-thread. And I never said that pokey can do anything the sid can. Quote Link to comment Share on other sites More sharing options...
analmux Posted May 22, 2008 Share Posted May 22, 2008 then the formula for F is different. For N>1 the formulas of triangle and sawtooth will differ a lot though. But, when using variable N allows us to get much finer control of the wanted frequency. What are the formulas for N>1? This is a lot less simple. When F3=F1+1, we know for sure that LCM(F1,F3)=F1*F3, as they are always relatively prime (here LCM is the least common multiple of two values). When f.e. F3=F1+2 then only for odd F1, we have LCM(F1,F3)=F1*F3. It's really a long story, but when F3 (=F1+N) and F1 are relatively prime, then there's still a nice formula. The positive thing is that for the purpose of getting better note precision this is exactly what we need: relatively prime pitches. So, when we do: POKE 53760,F1-4:POKE 53764,F3-4 where F3=F1+N, we get: PHI = LCM(F1,F3) =F1*F3 = F1*(F1+N). Now solve this by ABC-formula for quadratic functions. F1^2+N*F1-PHI=0 then: F1=(-N+SQR(N^2+4*PHI))/2 now, because we want P1 (=pitch1) = F1+4, and P3=P1+N, we get: P1=F1-4 = (-N+SQR(N^2+4*PHI)/2 -4=(-N-8+SQR(N^2+4*PHI)/2 you can check that this will obtain the original formula, when you choose N=1. There's another effect when using non-relatively-prime pitches: some subharmonic expansions will be added to the sound, such that it is not a pure sawtooth wave anymore, but a richer type of sound: The richness of Pokey features really lies in all the possible 'resonances' of more simple settings. This is only an example of a small part of Pokey's features. Some features may one day surprise all of us Quote Link to comment Share on other sites More sharing options...
analmux Posted May 23, 2008 Share Posted May 23, 2008 This is just one of the methods to generate these waveforms. Key comment is though that you shouldn't want these waveforms for low/bass notes. This is not possible on Pokey. hmm havent you said in the flame thread that pokey can do anything the sid can ? gotcha Reconsidering what I wrote back then: Saying that this is not possible on Pokey is not really true. The waveforms are available on the whole audible sound spectrum. For the deep bass notes though there are artefacts, as the two channels which are interfering get into the audible range, and produce pitches around 17 kHz e.a. which really hurt the ears. So, at these notes we are dealing with artefact superharmonics (as in fact they are harmonic overtones of the original triangle/sawtooth pitch). If you want lower notes, the best is to use N=1. This means less note accuracy, but because for the lower notes the pitch-stepping is larger this is compensated. For the higher pitches the resolution only gets better and better using different N, quite contrary to normal squarewaves. Quote Link to comment Share on other sites More sharing options...
Oswald Posted May 23, 2008 Share Posted May 23, 2008 Reconsidering what I wrote back then: Saying that Pokey can do anything a SID can is not really true. Because for the deep bass notes though there are artefacts, as the two channels which are interfering get into the audible range, and produce pitches around 17 kHz e.a. which really hurt the ears. So, at these notes we are dealing with artefact superharmonics (as in fact they are harmonic overtones of the original triangle/sawtooth pitch). Quote Link to comment Share on other sites More sharing options...
frogstar_robot Posted May 23, 2008 Share Posted May 23, 2008 Reconsidering what I wrote back then: Saying that Pokey can do anything a SID can is not really true. Because for the deep bass notes though there are artefacts, as the two channels which are interfering get into the audible range, and produce pitches around 17 kHz e.a. which really hurt the ears. So, at these notes we are dealing with artefact superharmonics (as in fact they are harmonic overtones of the original triangle/sawtooth pitch). *plonk* Quote Link to comment Share on other sites More sharing options...
analmux Posted May 23, 2008 Share Posted May 23, 2008 Reconsidering what I wrote back then: Saying that Pokey can do anything a SID can is not really true. Because for the deep bass notes though there are artefacts, as the two channels which are interfering get into the audible range, and produce pitches around 17 kHz e.a. which really hurt the ears. So, at these notes we are dealing with artefact superharmonics (as in fact they are harmonic overtones of the original triangle/sawtooth pitch). So, what is the point of misquoting me now Ozzy? You're quoting things I never said, and are not relevant. Really your only motivation to get involved in discussions here is to make a mess. So why no mention of what pokey can do easily and is not possible on SID? Because that doesn't fit with your picture that SID is 'lightyears better than pokey' ??? 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.