| |
Bago Zonde
Registered: Dec 2010 Posts: 29 |
SFX while playing 3 voices
Hello, this is my first post on this forum, so Hello everybody and a lot of greetings!!
I'm writing game for C64 in pure assembler and I want to ask You about some possibilities of sfx and digis. I'm newbie in assembler, just 2 month of programming (and few years with basic), but my progress with game called Meonlawel is really noticeable for me. There's usual loading, saving, move screen, changing chars (all in Hi-Res), playing music and controls so I see that assembler is really great, really :) !!! If somebody would to know more about Meonlawel, website will be available soon. However, due to this good progress and my growing faith in that project I'm curious about what sfx can do with bombarding $D418 while playing all 3 voices and how to do it? Music is playing from $8000 with IRQ. I was trying with some sounds e.g. nice & short (around one second perhaps) switch sound during main screen while selecting options.
So, can anyone could help me with easy procedure for test which can play primary SFX sound, because I was trying a little bit and I don't know if that's a good solution because only what I heard was stop playing one of voice channel and some truncate sounds.
I have no idea & experience what C64 could do for me in that category. I think that playing "fourth" channel simultaneously can't be done as one more voice in fact but it's possible in some ways to reach the target.
Sorry for my English and best wishes in upcoming 2011 ;).
Bartek
|
|
| |
Hein
Registered: Apr 2004 Posts: 954 |
Have you tried playing digis without music? On 6581 SID chip?
Music routines also use the $d418 register (mainly for filters during playtime), so you may have conflicts. |
| |
Bago Zonde
Registered: Dec 2010 Posts: 29 |
Hello, fanx for reply.
I've written a little procedure shown here. If unnecessary to include it - sorry for that, but maybe somebody would tell me if there's any mistakes (or somebody would use it if I'm right) because I'm learning C64's map from A to Z, for now fourth channel especially:
LDA #$00
STA $D412 ;Voice #3 Register (Gate=0)
LDA #$08
STA $D411
LDA #$00
STA $D410 ;Pulse Width to $0800 = 2048
LDA #$0F
STA $D418 ;Volume to 15
LDA #$41
STA $D412 ;Voice #3 Register set to pulse (Gate=1)
LDA #$69
STA $D413 ;Attack/Decay set to 6/9 = 6*16+9=105
LDA #$01
STA $D414 ;Sustain/Release set to 1
LDA #$10
STA $D40F
LDA #$08
STA $D40E ;Frequency set to 156.6 = $1008
and it's working properly but it's overriding #3 voice so "The Fourth" is just a legend? I thought there's really something. While SFX playing (it's just a longer pulse), tune's pitch is changed because of playing tune on voice #3 from subtune. And filter on voice #3 become changed after SFX have finished, I can heard only a burps.
So, is there any possibility to store all values from currently playing tune on voice #3, then turn off that voice to freely playing SFX, then if it's done, just restore values and unblock voice #3 for subtune? If yes, I could work on that. All because one of my subtunes is a little ambient music so sounds are playing for time to time, not too often.
I've tested that on real 6581 and on Vice emulator, on real C64 - unfortunately a filter is more quiet, but it's filters. Moreover all is that same on emulator and real C64.
|
| |
Stryyker
Registered: Dec 2001 Posts: 468 |
Have a look at the routine that plays the music. Some have easy methods of blocking one voice. |
| |
Hein
Registered: Apr 2004 Posts: 954 |
I thought you were talking about digis, the magical 4th channel :)
International Karate, Bangkok Knights, Mega Apocalypse for example use digis while playing 3 channel music.
Goattracker contains an sfx routine that temporarily disables the 3rd channel. No idea about other music routines. |
| |
Bago Zonde
Registered: Dec 2010 Posts: 29 |
Hein, so if I'll include digis player, not just this procedure playing sounds and find something what can block one of voices for a while, there's a chance to play digis? I found some informations about digis but I can't understand it at all. I have some digis on diskette, so I'll try to use them. I have not idea what to do with it for now. Is it alright going that way? Of course "magical 4th channel" is just one of 3 available voices overriding, yes?
|
| |
Isildur
Registered: Sep 2006 Posts: 275 |
Quote: Hein, so if I'll include digis player, not just this procedure playing sounds and find something what can block one of voices for a while, there's a chance to play digis? I found some informations about digis but I can't understand it at all. I have some digis on diskette, so I'll try to use them. I have not idea what to do with it for now. Is it alright going that way? Of course "magical 4th channel" is just one of 3 available voices overriding, yes?
4th channel is just an illusion, but it sounds like 4th channel :)
Depends on what player you use, there are switches to disable 1 to 3 channels.
Another option is to compose tune with two channels and use 3rd to sfx. |
| |
Bago Zonde
Registered: Dec 2010 Posts: 29 |
So if it's just an illusion, I should switch off one of channels for a while then turn it on when SFX sound it's done. Something like priority.
However I don't know how to do it, but I'll try with some more practise and more diggin'.
Maybe somebody know how to do it with Goat Tracker subtunes?
I found only that for init SFX in GT manual:
LDA #<effect ;Start address of sound effect data
LDY #>effect
LDX #channel ;0, 7 or 14 for channels 1-3
JSR startaddress+6
But I don't know for now what will exactly happen.
Working with 2 voices is of course a good idea, but I want only a few SFX signals during gameplay (selecting options, opening doors, maybe some sounds when magic released) and music tunes are more important to me so it should be expanded to 3 voices for more interesting music. However I'm not so great to squeeze 3 channels into 2, that's job for masters of sounds :).
|
| |
Isildur
Registered: Sep 2006 Posts: 275 |
How about to skip playing routine for a sec during sfx?
little algorithm :)
if need sfx jump to skip:
...
...
jst $1003 ;play tune
...
...
skip: play SFX
...
...
|
| |
Bago Zonde
Registered: Dec 2010 Posts: 29 |
Yeah, but no need to switch off all voices, I should find solution for disabling one channel in that way You described. |
| |
GT Account closed
Registered: Sep 2008 Posts: 308 |
Adjust the music player to ignore writes to the SID register of the chosen voice/s you want to use for SFX when they occour. But keep the music player running. |
| |
Hein
Registered: Apr 2004 Posts: 954 |
Goattracker's SFX are limited, but if you read the paragraph about SFX in GT's manual, you'll figure it out.
Have you tried doing sfx without music? I mean, in order to play sfx at all, you'll need an sfx routine. If you're at a starting point of SID fiddling, I think trying Goattracker's sfx support is a good way to learn the basic SID writes. You can save GT instruments as small sfx tables and embed those into your game source code. Export your 3 channel GT music incl. sfx support. Use the lda #<sfx_in_source ldy #>sfx_in_source ldx #channel and jsr to the magical 4th channel init routine.
Once that's settled and working with 3 channel Goattracker music, you can write your own sfx routine and hack your way into your prefered music routine the way Geir proposes. |
| |
TWW
Registered: Jul 2009 Posts: 545 |
Not exactly my strong field the SID but:
Isn't there a way to do music & digis by playing 3 bit digis on the 3 LSB's of $d418 and keeping bit #3 set? |
| |
Fungus
Registered: Sep 2002 Posts: 686 |
I have a bit of a question regarding this too. Not exactly the same but sort of. Anywho...
Is it possible to "multiplex" the sid much like say a sprite multiplexer, and play a 3 voice tune, and 1 or 2 voice sound effects also (at a 50% difference in raster) to give the illusion of both sound effects and a full tune?
|
| |
Bago Zonde
Registered: Dec 2010 Posts: 29 |
Yesterday I managed to get sfx sound on a chosen channel and it's working quite well because subtune procedure can play sfx sound in easy way and when sfx is finished, subtune plays on automatically.
So, in Goat Tracker I packed subtune choosing Sound Effect support. Then I exported one of instruments to SND with INS2SND2.exe and opened output to rewrite sound table to code (at a given address e.g. $0E80). While a button key is pushed, there's a simple skip to play SFX which turns off one of chosen voice:
LDA #$80
LDY #$0E
LDX #$00 ;voice ($00 for #1, $07 for #2, $0E for #3)
JSR startaddress+6
(with SFX support, changing volume is possible from startaddress+9, not startaddress+6)
Of course on of voices is overrides for a while so it's not a magical fourth channel, but it's work quite well.
If anybody have some idea how to make that 4th channel more hearable/usable, that will be very interesting to know how to do it.
|
| |
Hein
Registered: Apr 2004 Posts: 954 |
Digis (4th channel) are quite simple to accomplish. Basicly it's this:
loop
lda #samplebyte
and #$0f
----only low nybble
sta $d418
pause....
lda #samplebyte
lsr
lsr
lsr
lsr
----high nybble is now low nybble
sta $d418
pause....
jmp loop
The pause-length does the pitch thing, 2 sample-nybbles in one byte save you some memory.
I never created a digi player other than some outside interrupt tests, but you can play digis best with timer interrupts (NMI preferably, because they have highest priority). So the timer triggers an interrupt that pokes the low nybble to $d418. Timer value is the pause-length and thus the pitch.
Digis are often not used, because you'll need to update $d418 alot of times per frame, eating CPU.
If you play digis outside interrupt, your game plays smoothly and all spare CPU time is used for your digis. But if your game uses alot of CPU, your spare CPU time is limited and the digis sound like crap.
That's why NMI is used in digi-music Savage, Outrun Turbo, Afterburner and such.
|
| |
Conrad
Registered: Nov 2006 Posts: 849 |
Quote: Not exactly my strong field the SID but:
Isn't there a way to do music & digis by playing 3 bit digis on the 3 LSB's of $d418 and keeping bit #3 set?
Ofcourse... Simply AND the value from $d418 with #$18, then ORA with the sample value that's 3 bits.
There's no real difference from having bit 3 set on or off, as the amplitude of the sample will always be in 3-bit range anyway. ... and you'll only get 75% of volume compared to 100% 4-bit digi'ing, making the sample output sound quieter. To save space you would also need to have an algo to read 3 bits of sample each time from each byte, which on the long run would use more cycles for processing a sample to output and losing the higher range of pitch. |