Jump to content
IGNORED

RMT : Interrupt the music to play a sound effect


snicklin

Recommended Posts

I am looking to add some sound effects into my game and was wondering how to handle it?

 

I have music already playing in the background and I would like to temporarily pause the music, play the sound effect once and then continue the music where it left off.

 

How do I do this with RMT? Do I need the sound effects somehow encoded into the RMT file with the music? Or can I load two files (one for music, one for effects) and then just point at which one I want?

 

Has anyone done this before? I guess it must have been...

Link to comment
Share on other sites

It's been a while, but...

 

IIRC there's a seperate call you can do to RMT to playback pre-defined effects. I'm not sure if you have to do your tune with less voices to begin with or if it just overrides given voice.

 

Alternatively you could just suspend your calls to playback, silence all voices and play your effect, then resume playback calls.

Alternately #2 you could alter the RMT playback routine, remove the end part where it stores to Pokey registers from the shadows.

Do that part yourself - if you have effects that need playing then they'll just override what RMT was going to do for that voice.

 

Note of course that there's potential for trouble there if you use a voice that's needed for multi-voice effects like 16-bit, filtered, saw/triangle etc.

Link to comment
Share on other sites

Example executable from rmt128:

 

sfx.xex

 

Look in the asm_src/sfx directory of the rmt128.zip package (website) to see an example of playing a song and sound effects simultaneously. No need to stop the music unless you really want to. Just call set RMTSFXVOLUME to the volume you want the effect played at, and call RASTERMUSICTRACKER+15 with the following parameters:

 

  A=note(0,..,60),X=channel(0,..,3 or 0,..,7),Y=instrument*2(0,2,4,..,126)

Create your sound effects as instruments in RMT. The sound effect will override the song's instruments for the given channel.

 

You can use a similar technique with TMC2 and CMC. Just create instruments for the effects and use the play-instrument interface to play them when desired while the music continues in the background.

  • Like 2
Link to comment
Share on other sites

Thank you both gentlemen for your input here.

 

Thanks to yourselves I am now able to play sound effects from within my code.

 

Now I have a couple more questions which lead off from here....

 

a) My music is currently overpowering the sound effects. I could lower the volume in RMT itself and save the file or I could lower it while the sound effects play and then increase the volume afterwards (perhaps faded back up). Is there a location that I can poke to amend the volume of the main music? I have the sfx at full volume.

 

b) I guess the answer to the following is "no" but I'll try anyhow. Is there a command line interface in any way so that I can import instruments into a .rmt file without doing it via the GUI? This isn't crucial but a nice to have for my build system.

Link to comment
Share on other sites

I think you need to select certain options within the RMT created source file before assembling to enable volume control. I suspect that global volume control though would also affect your sfx which makes it not useful in your case.

What's probably needed is to redefine the other instruments such that they're quieter. Or maybe go the way of modifying the RMT routine such that it only maintains the Pokey shadows, then have your own routine that attenuates the volume if required when your sfx are active. To do that you'd probably want some translation tables which alter each volume value, or maybe just use bitshift to divide by 2.

 

The way I'd go about it is probably just redefine instruments so they're quieter, e.g. nothing peaking above volume level 10, then have your effects at a higher peak to make them stand out more.

Link to comment
Share on other sites

Yes, I've been looking through the defines for compiling the code for lower volume in the music but I couldn't find a control to be able to do that. However, I believe that I have probably just not spotted it. I'll keep on looking.

 

I'm kind of loathed to going in and changing the volumes of instruments and the song itself because I would like to use songs supplied by Miker (as-is with how they are supplied). And I want to leave myself open to the option of having lots of different songs (I currently have 2) depending on disk space. I don't want to change all instruments in all songs if I can help it. I'd rather run them through code which limits volume instead.

 

I could do that though if there is no other option. Thanks for your valuable input once more.

Link to comment
Share on other sites

I've got RMTGLOBALVOLUMEFADE set to 224 to try and keep the music low in volume but it doesn't seem to have made an effect. I also question that because it has the word "global" in it, will it also make the sound effects quieter?

 

I've got the RMTSFXVOLUME set to the highest volume so that they stand out above the game music.

 

Thanks for your input. I can confirm that I am using 1.28 by the way.

Link to comment
Share on other sites

I'm kind of loathed to going in and changing the volumes of instruments and the song itself because I would like to use songs supplied by Miker (as-is with how they are supplied). And I want to leave myself open to the option of having lots of different songs (I currently have 2) depending on disk space. I don't want to change all instruments in all songs if I can help it. I'd rather run them through code which limits volume instead.

 

Ah you haven't quit understood how it works. Let me help you. You write an email to Miker and tell HIM to lower the volume of all instruments ;)

Seriously, I haven't thought about this till now, and it turned out quit Ok. But now I will tell my OSon to use lower volume Instruments from the start.

Haven't checked how the RMT replay does the lower volume, however, doing it manually before hand is the best option, I think.

What you should not forget: There is more then just the volume. A high pitch will be more recognizable then a lower pitched melody instruments.

Finally, music instruments use probably a volume envelope, so they are not always at level 15. And an explosion or pick-up of an item has a fast attack and can be very well recognizable when played. Additionally, the player has some expectation that he hears a sound when he picks up or does something. So he hears the sfx pretty easily.

Keep in mind, that there is some kind of limit in POKEY. Something along the lines that the added volume of all channels shouldn't be higher then 30 or so. Should be in the ABBUC-SW-Contest tips and tricks sheet. So, lowering the instruments is a good idea anyhow ;)

Link to comment
Share on other sites

There was a mentioned limit, I think it was DeRe Atari with combined volume of 15 - IMO it's a total bunch of crap, we've all had Pokeys for over 30 years being belted with full volume.

 

The problem with just using much lower volume is the amplitude steps are very noticable at lower levels, e.g. cycling through 5-10 vs 10-15.

Link to comment
Share on other sites

There was a mentioned limit, I think it was DeRe Atari with combined volume of 15 - IMO it's a total bunch of crap, we've all had Pokeys for over 30 years being belted with full volume.

 

So we should ask JAC! where he got his info from, I guess :)

http://www.wudsn.com/index.php/productions-atari800/tutorials/tips

 

This is defo not my expertise, so after I have mentioned this fact it's time for me to leave ;)

Link to comment
Share on other sites

Yes, that's from De Re. I had to rely on that as I'm over 40, so my personal judgement output audio quality is limited by my worn out ears.

>http://www.atariarchives.org/dere/chapt07.php#H7_2_3

"The sum of the volumes of the four channels should not exceed 32, since this forces overmodulation of the audio output. The sound produced tends to actually lose volume and assume a buzzing quality."

Edited by JAC!
Link to comment
Share on other sites

"Overmodulation" - I've got doubts about that.

 

If it did happen, then surely a use would be found for it, it would almost be like being given new waveforms... though you'd need to use 3 voices minimum to actually get it.

 

New waveforms?

If the described effect is the one you hear in the Intro of my "MJO" then it is certainly unwanted an annoying.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...