AGD - How to play AY sound effects WITH music?

On the creation of AY or Beeper music, including the packages used to do so.
Post Reply
User avatar
Lee Bee
Dynamite Dan
Posts: 1297
Joined: Sat Nov 16, 2019 11:01 pm
Location: Devon, England
Contact:

AGD - How to play AY sound effects WITH music?

Post 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?
User avatar
Ivanzx
Manic Miner
Posts: 736
Joined: Tue Nov 14, 2017 9:51 am

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

Post 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!
User avatar
deanysoft
Dizzy
Posts: 75
Joined: Sat Jun 18, 2022 10:35 pm

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

Post 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.
Nienn Heskil
Microbot
Posts: 134
Joined: Tue Jun 09, 2020 6:14 am
Contact:

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

Post 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' ~
User avatar
deanysoft
Dizzy
Posts: 75
Joined: Sat Jun 18, 2022 10:35 pm

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

Post 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...
User avatar
Lee Bee
Dynamite Dan
Posts: 1297
Joined: Sat Nov 16, 2019 11:01 pm
Location: Devon, England
Contact:

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

Post 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!
Nienn Heskil
Microbot
Posts: 134
Joined: Tue Jun 09, 2020 6:14 am
Contact:

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

Post 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.
User avatar
Lee Bee
Dynamite Dan
Posts: 1297
Joined: Sat Nov 16, 2019 11:01 pm
Location: Devon, England
Contact:

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

Post 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.
Nienn Heskil
Microbot
Posts: 134
Joined: Tue Jun 09, 2020 6:14 am
Contact:

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

Post 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. :)
XoRRoX
Manic Miner
Posts: 233
Joined: Wed Jul 11, 2018 6:34 am

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

Post 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.
Nienn Heskil
Microbot
Posts: 134
Joined: Tue Jun 09, 2020 6:14 am
Contact:

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

Post 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.
XoRRoX
Manic Miner
Posts: 233
Joined: Wed Jul 11, 2018 6:34 am

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

Post 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.
Nienn Heskil
Microbot
Posts: 134
Joined: Tue Jun 09, 2020 6:14 am
Contact:

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

Post by Nienn Heskil »

Glad it helped!
XoRRoX
Manic Miner
Posts: 233
Joined: Wed Jul 11, 2018 6:34 am

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

Post 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?
User avatar
Joefish
Rick Dangerous
Posts: 2059
Joined: Tue Nov 14, 2017 10:26 am

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

Post 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.
User avatar
Lee Bee
Dynamite Dan
Posts: 1297
Joined: Sat Nov 16, 2019 11:01 pm
Location: Devon, England
Contact:

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

Post 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.
Nienn Heskil
Microbot
Posts: 134
Joined: Tue Jun 09, 2020 6:14 am
Contact:

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

Post 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.
highrise
Manic Miner
Posts: 305
Joined: Fri Mar 20, 2020 11:29 pm

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

Post 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.
Post Reply