Page 1 of 2

AGD - How to play AY sound effects WITH music?

Posted: Fri Apr 07, 2023 1:11 am
by Lee Bee
Is there any way to play an AY sound effect in 1 channel while background music continues playing in the other 2 channels?

Alternatively, is there a way to begin playing a tune from a specific point? So you can resume background music when a sound effect has ended?

Re: AGD - How to play AY sound effects WITH music?

Posted: Fri Apr 07, 2023 1:14 am
by Ivanzx
I think so, I have been playing Hakkenkast lately and it does have AY music and sounds at the same time :)

Some of the tech gurus will probably know better and how!

Re: AGD - How to play AY sound effects WITH music?

Posted: Sat Apr 08, 2023 4:05 pm
by deanysoft
Absolutely you can. You can do whatever you want as the channels are mostly separate (I say mostly as there's only one noise frequency although you can have a noise on each channel!).

My AY driver usually plays a 3 channel tune but for my latest endeavour, I wanted in-game music and AY effects so I did exactly that. 2 doing the music and one for FX. The driver is always processing the 3 under interrupt so I just trigger an FX in the game and the FX is just output naturally as part of the 3 channel driver. The FX are just short bursts of tune, arpeggio chords or noise. I did consider stealing a channel temporarily for FX but found that I could get a half decent tune with just 2 channels anyway - especially if one is also adding some noise in for 'percussion' (such as it is!)

The only slight complication was modding it so the 2 channel tunes would restart seamlessly if required.

Re: AGD - How to play AY sound effects WITH music?

Posted: Sat Apr 08, 2023 4:40 pm
by Nienn Heskil
It's also possible to use all 3 channels for music and add the FX in a 'safe' way (e.g.play noise-based fx frames in parallel with tone-based music frames etc), because lol why not and 3>2 anyway. I've made an FX player like that some time back (ayfx compatible), that works with most AY music players with a slight modification

But he is specifically saying 'AGD' here, which in this context normally means 'don't bother, any of that is probably useless here' ~

Re: AGD - How to play AY sound effects WITH music?

Posted: Sat Apr 08, 2023 6:07 pm
by deanysoft
Ah! My mistake. I missed the obvious 'AGD' bit. In that case, I'm useless as I've never seen AGD - kindly disregard all my ramblings...

Re: AGD - How to play AY sound effects WITH music?

Posted: Tue Apr 11, 2023 2:19 pm
by Lee Bee
Thanks, anyway, chaps.

Sorry, I should probably have made the "AGD" bit more prominent. I'm currently working on some audio for a developer who's using AGD and simply wants to use a few AY sound effects (because they sound good) without the music resetting every time a sound effect plays! You'd think that wouldn't be too much to ask :-)
Nienn Heskil wrote: Sat Apr 08, 2023 4:40 pm It's also possible to use all 3 channels for music and add the FX in a 'safe' way (e.g.play noise-based fx frames in parallel with tone-based music frames etc), because lol why not and 3>2 anyway. I've made an FX player like that some time back (ayfx compatible), that works with most AY music players with a slight modification
As clever as that sounds, I'd find it unthinkable to make either music or sound effects that weren't allowed both noise and tones!

Re: AGD - How to play AY sound effects WITH music?

Posted: Tue Apr 11, 2023 3:09 pm
by Nienn Heskil
:lol: What I mean is, to play only the stuff that the currently-playing effect uses at the current moment (whether tone, noise or both), and leave other things in the channel 'mostly' untouched, rather than switch them off completely.

In any case, if you guys can work with ASM code, feel free to check it out:
mFX - source code
mFX - test package (run .SNA and press keys 1-5)
I've never got to make a proper package with docs and whatnot, but the source code should be fully commented and usable.

Re: AGD - How to play AY sound effects WITH music?

Posted: Tue Apr 11, 2023 8:53 pm
by Lee Bee
Nienn Heskil wrote: Tue Apr 11, 2023 3:09 pm :lol: What I mean is, to play only the stuff that the currently-playing effect uses at the current moment (whether tone, noise or both), and leave other things in the channel 'mostly' untouched, rather than switch them off completely.
Ooooh, I see. That would probably be helpful, especially if you had a game with mostly noise-based sound effects that could share with a music channel containing no noise.

But there's always the problem of envelope priority - what happens when both your sound effects and music use an envelope (which for me is typical). Even Arkos Tracker, with its powerful SFX support, doesn't allow management of this issue.

Re: AGD - How to play AY sound effects WITH music?

Posted: Wed Apr 12, 2023 8:46 am
by Nienn Heskil
Lee Bee wrote: Tue Apr 11, 2023 8:53 pm But there's always the problem of envelope priority - what happens when both your sound effects and music use an envelope (which for me is typical). Even Arkos Tracker, with its powerful SFX support, doesn't allow management of this issue.
Yes, that's one of the limitations that can't be helped much regardless of the player. Using the hardware envelope of the AY in a channel excludes the usage of (regular) channel volume settings, which is what sfx normally use.

If you think about possible solutions to this problem, it more or less comes down to this: either play the fx OR the (hw envelope parts) cleanly, or somehow play both but likely very distorted, or not in a way that makes a lot of sense anyway. In other words, it's just one type of clashing vs another type of clashing. Which is why it's reasonable to go for the easier option. :)

Re: AGD - How to play AY sound effects WITH music?

Posted: Tue Apr 25, 2023 7:56 pm
by XoRRoX
I vaguely remember a player that looked for the least busy channel and played the fx on that. Sorry for not remembering the exact name.

Re: AGD - How to play AY sound effects WITH music?

Posted: Wed Apr 26, 2023 8:47 am
by Nienn Heskil
XoRRoX wrote: Tue Apr 25, 2023 7:56 pm I vaguely remember a player that looked for the least busy channel and played the fx on that. Sorry for not remembering the exact name.
Not a good method - plenty of machines have the AY output as stereo, and it's gonna be a mess in that case.

Re: AGD - How to play AY sound effects WITH music?

Posted: Fri Aug 25, 2023 11:52 am
by XoRRoX
Nienn Heskil wrote: Tue Apr 11, 2023 3:09 pm :lol: What I mean is, to play only the stuff that the currently-playing effect uses at the current moment (whether tone, noise or both), and leave other things in the channel 'mostly' untouched, rather than switch them off completely.

In any case, if you guys can work with ASM code, feel free to check it out:
mFX - source code
mFX - test package (run .SNA and press keys 1-5)
I've never got to make a proper package with docs and whatnot, but the source code should be fully commented and usable.
Just got around to testing it and it works great :) 8-)
Thank you for sharing.

Re: AGD - How to play AY sound effects WITH music?

Posted: Fri Aug 25, 2023 9:21 pm
by Nienn Heskil
Glad it helped!

Re: AGD - How to play AY sound effects WITH music?

Posted: Sun Mar 31, 2024 9:00 pm
by XoRRoX
@Nienn Heskil

I just read about a fixed AYFX player by Haplo: https://www.zxuno.com/forum/viewtopic.php?f=39&t=643
In your mFX code, is this fix incorporated?

Re: AGD - How to play AY sound effects WITH music?

Posted: Tue Apr 02, 2024 12:17 pm
by Joefish
What happens if you enable noise on more that one channel? Is it any louder? Or is it just the same as when it's on one channel?
I can see how maybe you could temporarily override the setting of noise pitch for your sound effect, but continue to use noise on your music channel for percussion. Would you even be able to hear that it was still being used for percussion while an explosion is sounding?

I assume the best solution is to design the tune with one channel deliberately under-used, e.g. a quieter accompaniment to the main melody and bass / percussion on the other two channels. Something that won't particularly be missed if it drops out to make sound effects. (Although I gather you couldn't do this in AGD). Simplest is to write a 2-channel tune with no noise-based percussion, then do your effects on one channel with noise and envelopes (unless your tune uses bass envelopes, in which case your effects have to go without).

I think it's also important to keep your effects in notably different frequency / octave regions, and louder than, your tune. That 128K music update to R-Type, where the melody drops out to allow the main gun firing pew-pew noise (which is in the same tonal range and volume as the melody) sounds absolutely terrible.

Re: AGD - How to play AY sound effects WITH music?

Posted: Thu Apr 04, 2024 11:41 am
by Lee Bee
Joefish wrote: Tue Apr 02, 2024 12:17 pm What happens if you enable noise on more that one channel? Is it any louder?
Noise on two channels at once doesn't sound any louder, only distorted and unpleasant, so I avoid it as best as I can. Saying that, brief noise clashes aren't too noticeable and it's no big deal for SFX noise to briefly clash with drum noise.

However, envelopes on two channels at once is the opposite. For music, it can add harmonics and a "thicker texture" to the sound, great for a "rock" sound. On the other hand, it is truly dangerous mixing enveloped SFX and music together, since the pitches will be different, and you'll either ruin the SFX or the music.

In summary, my rules are:

Image
Joefish wrote: Tue Apr 02, 2024 12:17 pm I assume the best solution is to design the tune with one channel deliberately under-used, […] Something that won't particularly be missed if it drops out to make sound effects.
Yes this technique should be essential for games where SFX can interrupt music tracks. I've always called it "2.5 channel" music. You bring all the least important sounds together into the ".5 channel" to be ducked while SFX plays. Which sounds you "duck" depends on the type and frequency of the game's sound effects and what sounds best.

Games which don't use this principle can be extremely irritating on the ears, as you note:
Joefish wrote: Tue Apr 02, 2024 12:17 pm That 128K music update to R-Type, where the melody drops out to allow the main gun firing pew-pew noise (which is in the same tonal range and volume as the melody) sounds absolutely terrible.
Agreed! :lol: You mean this. I started making my own version of the R-Type level 1 tune. It makes full use of all 3 channels, but in reality if I were making music for a game like R-type with near-constant SFX, the tune would basically be 2 channels with a few subtle embellishments in the third channel.

I suppose a "dream" Spectrum audio engine would let you supply both a 3-channel and 2-chanell version of in-game music, with the engine switching to the 2-channel version during SFX play.
Joefish wrote: Tue Apr 02, 2024 12:17 pm I think it's also important to keep your effects in notably different frequency / octave regions, and louder than, your tune.
Agreed. As a musician, I try to keep ALL parts as tonally separate as possible to avoid a "muddy" mix. Being a lover of clarity, I also personally limit myself to a maximum of 3 simultaneous melodic parts in any piece of music. It's one of the reasons I think Speccy music sounds good as it has fewer parts.

Re: AGD - How to play AY sound effects WITH music?

Posted: Wed Apr 24, 2024 10:34 am
by Nienn Heskil
XoRRoX wrote: Sun Mar 31, 2024 9:00 pm @Nienn Heskil

I just read about a fixed AYFX player by Haplo: https://www.zxuno.com/forum/viewtopic.php?f=39&t=643
In your mFX code, is this fix incorporated?
It doesn't say exactly what was the bug and/or where is the fix, so it's hard to say. Iirc I rewrote the player from scratch for mFX, and may (or may not) have noticed/fixed some bugs from the original player at the time, but I'm not aware of any in my version.

Re: AGD - How to play AY sound effects WITH music?

Posted: Fri Apr 26, 2024 5:49 pm
by highrise
just to add, one alternative would be to use something like Shiru's AYFX player, and to create simple tunes which are sound effects, and play them using some kind of a timer.

Re: AGD - How to play AY sound effects WITH music?

Posted: Sat May 04, 2024 9:58 am
by Cheez26
One of my proposed methods is using the beeper as a dedicated card for sound effects so I can use AY for music, but I'm not sure if that'll work since I've realized that not every model has a beeper and would only have AY.

Re: AGD - How to play AY sound effects WITH music?

Posted: Sat May 04, 2024 10:25 am
by AndyC
Cheez26 wrote: Sat May 04, 2024 9:58 am One of my proposed methods is using the beeper as a dedicated card for sound effects so I can use AY for music, but I'm not sure if that'll work since I've realized that not every model has a beeper and would only have AY.
Every Spectrum has a beeper. And it wasn't uncommon back in the day to do sound effects via the beeper and music via AY, that way you didn't need to change things between the 48 and 128 machines.

Re: AGD - How to play AY sound effects WITH music?

Posted: Sat May 04, 2024 10:30 am
by jorgegv
Cheez26 wrote: Sat May 04, 2024 9:58 am One of my proposed methods is using the beeper as a dedicated card for sound effects so I can use AY for music, but I'm not sure if that'll work since I've realized that not every model has a beeper and would only have AY.
We use that method in Cesare and It works very well.

Re: AGD - How to play AY sound effects WITH music?

Posted: Sat May 04, 2024 10:39 am
by Cheez26
jorgegv wrote: Sat May 04, 2024 10:30 am We use that method in Cesare and It works very well.
AndyC wrote: Sat May 04, 2024 10:25 am Every Spectrum has a beeper. And it wasn't uncommon back in the day to do sound effects via the beeper and music via AY, that way you didn't need to change things between the 48 and 128 machines.
Well, this is all good to know. Thanks. :dance

Re: AGD - How to play AY sound effects WITH music?

Posted: Sat May 04, 2024 2:16 pm
by Lee Bee
Beeper SFX with AY music is fairly standard and seems to be the only system you can use in AGD.

Re: AGD - How to play AY sound effects WITH music?

Posted: Sat May 04, 2024 2:22 pm
by Cheez26
Lee Bee wrote: Sat May 04, 2024 2:16 pm Beeper SFX with AY music is fairly standard and seems to be the only system you can use in AGD.
There's also AGDX+ which is a mod/upgrade of AGD. and has an AYFX option/command somewhere. Otherwise, yeah, I would guess so.

Re: AGD - How to play AY sound effects WITH music?

Posted: Sat May 04, 2024 4:08 pm
by Lee Bee
Cheez26 wrote: Sat May 04, 2024 2:22 pm There's also AGDX+ which is a mod/upgrade of AGD. and has an AYFX option/command somewhere.
Oh if that's true then you've solved this question for me, thanks!