Shop OBEX P1 Docs P2 Docs Learn Events
Simple game sounds — Parallax Forums

Simple game sounds

Michel LMichel L Posts: 141
edited 2013-01-05 05:46 in Propeller 1
I have made a couple small projects with the propeller of which my last (and biggest one) was a clock with timer and alarm functions.

This weekend I have planned to create asteroids.
My plan is to make something structured like this (I have always problems structuring my projects. I'm a Java programmer so I'm used to pass objects through)
Main loop (game logic in non blocking loop)
|- VGA Vector driver (1 cog)
|- Human control (1 cog)
|- Sound (1 cog)
| |- Sound generator (1 cog)

I have found a couple objects SNEcog, AYcog, SIDcog, gm_synth with which I could generate my sound.
But the problem is that I'm not really playing music. It's mainly sound fx. (Asteroids players will know that the original version didn't include music)
Maybe I'll add them If I get done too early. (Probably not :p )

What I'm looking to do is make an object (running in its own cog) with some methods like: shot_fired, asteroid_hit,...
Each of these functions would then play a short piece of sound through one of the previously mentioned objects. (I haven't decided which one yet, any recommendations?)
But this gives a problem with overlapping sounds. Any ideas how I can fix this without using multiple sound objects?

Thanks in advance for any hints

Comments

  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2012-12-11 11:05
    A great place to start would be to check out the documentation and program examples for the Propeller powered Hydra game console:

    http://www.parallax.com/StoreSearchResults/tabid/768/txtSearch/hydra/List/0/SortField/4/ProductID/467/Default.aspx

    Go toward the bottom of the page where there are links to the documentation and software. There is a whole section on sound effects that should help.

    Robert
  • Ahle2Ahle2 Posts: 1,179
    edited 2012-12-11 14:49
    SNEcog, AYcog and SIDcog are all emulations of PSGs used in the 80s mostly for sound effects. (well the SID was more about music actually)
    The AY-3-8910 (AYcog) was without a doubt the most used sound chip in arcade machines until about 1987 or so. So it will definitely give the most "authentic" retro sound effects.
    The "trick" to make retro sound effects is simply: "Change PSG registers over time"; That's the way it was done in the 80s and that's the way you have to do it today if you want authentic retro sound effects.
    Back then there was not any easy ways to do sound effects.

    My unreleased Retronitus sound engine would probably fit like a glove for what you want to do. It
    just takes a single cog and can handle both music and sound effects at the same time.
    And MOST importantly, you don't need to manually change registers over time to achieve sound effects (or music). Load a "pre defined register write file" (well, it actually is a program running in Retronitus) into memory and a simple call to a method will do everything for you.

    IMHO the sound generators provided with the Hydra will not give you true retro sound effects because they do sound generation differently compared to PSGs from the 80s.


  • Michel LMichel L Posts: 141
    edited 2012-12-12 08:19
    Thanks both, I've looked through the hydra documentation but I didn't really find a clear way of doing my sound fx.

    My idea now is to split sound fx and music.
    I have found a version of your Retronitus with some fx files included. And I would like to use that to do my fx.
    As your editor is not yet released I think it would be very hard to make a song. Short sound effects based on the ones included should be possible.

    For my music I would then use gm_synth (http://forums.parallax.com/showthread.php?111867-Music-Synthesizer-object-with-General-MIDI-sound-set).

    Is it possible to mix the output of Retronitus with the gm_synth using the stereo spatializer? (http://obex.parallax.com/objects/64/)
    Or does Retronitus really need it 2 outputs as physical pins?

    Is this setup feasible? I know the stereo spatializer can work with 4 vocaltrackts. But I would not know how to couple the gm_synth or Retronitus with it.
  • Ahle2Ahle2 Posts: 1,179
    edited 2012-12-12 23:39
    Is it possible to mix the output of Retronitus with the gm_synth using the stereo spatializer? (http://obex.parallax.com/objects/64/)
    Of course it is, but you will be facing the same problems as others who use stereo spatializer for mixing signals of different sample rates. It spells "aliasing" and it really is a horrible thing.

    I can help you to do music and sound FX for Retronitus. Maybe that will help me to be motivated to finish the editor as well. :)
  • Michel LMichel L Posts: 141
    edited 2012-12-13 02:48
    Ahle2 wrote: »
    Of course it is, but you will be facing the same problems as others who use stereo spatializer for mixing signals of different sample rates. It spells "aliasing" and it really is a horrible thing.
    Ow, I didn't know that. I only found it used with multiple vocaltracts.
    Ahle2 wrote: »
    I can help you to do music and sound FX for Retronitus. Maybe that will help me to be motivated to finish the editor as well. :)
    That would be nice, only, this project is something I will make this weekend together with a friend. I can't expect you to create my music this weekend.

    I have opened the sound files using a hex editor an I also have been through your code. Although I've not yet fully understood the format you use I hope I will be able to this evening. So that I know what I'm doing if I change a soundfx file.

    Maybe I can borrow your editor this weekend or; as I'm a software engineer myself I could maybe even help in the development. I'm always looking for nice projects to support.
  • Ahle2Ahle2 Posts: 1,179
    edited 2012-12-13 10:39
    Ow, I didn't know that. I only found it used with multiple vocaltracts.
    It works wonders when all the sound generators runs at the same sample rate as the stereo spatializer. (7 monks etc).
    I have opened the sound files using a hex editor an I also have been through your code. Although I've not yet fully understood the format you use I hope I will be able to this evening. So that I know what I'm doing if I change a soundfx file.
    I don't think you will be able to decode the "format" before the weekend. You can't directly write to Retronitus internal registers. Retronitus sound FX is actually code that runs in the cog and "tweeks" the internal register over time.
    Maybe I can borrow your editor this weekend
    Maybe you can. The sound FX part of the editor actually works perfectly. I will get back with more info tomorrow.

    Btw, I have included a zip-file with FX created in my editor.

    RetronitusSoundFx.7z

    You will have to try each FX in the different sound channels to find out which gives the best results.
    Most FX should be played in one of the square channels, but some FX may sound best in a Saw, Tri or Noise channel.
  • Ahle2Ahle2 Posts: 1,179
    edited 2012-12-15 07:20
    Sorry I was not able to find a version of the editor that works good enough for you to use. I know I have a newer version laying around somewhere, but I couldn't find it. :(
  • Michel LMichel L Posts: 141
    edited 2012-12-16 14:37
    Because the graphics driver 1 found for vector based images used tv output and I didn't succeed in changing it to vga, nor did I find anything capable of what I needed for vga (There is a pixel plotting driver, but the demo really slows down if you enlarge it to 320/240. And with 640/480 it doesn't have enough memory) I changed to breakout.

    I wanted to do my sound fx each time I bumped into a wall or brick. The weird thing was that only the first time I played the sound fx it played correctly. The second time it always went weird. Is this normal behavior, something that was changed in a more recent version or a bug?
    I had it with multiple fx files (amongst them was "bump"). Both the sound files I used and the Retronitus source came from RetronitusTeaser.
  • Ahle2Ahle2 Posts: 1,179
    edited 2012-12-17 02:31
    I think I have to see the code to be able to give you an answer.
    I don't know of any bugs in the engine. (yet)
  • Michel LMichel L Posts: 141
    edited 2012-12-22 09:07
    Ahle2 wrote: »
    I think I have to see the code to be able to give you an answer.)

    Breakout - Archive [Date 2012.12.22 Time 18.02].zip
    Here you go. It's made using the demoboard with a vga screen, ps/2 mouse and some speakers/headphones.
  • Ahle2Ahle2 Posts: 1,179
    edited 2013-01-04 11:24
    I finally got the time to test your code. And as far as I can tell, the sound FX gets called EVERY frame and not just when something get hit.

    The following if statement is true every frame.
    if _XDir <> XDir | _YDir <> YDir
      retronitus.playSoundFX(7, @BreakBlock)
    
  • Michel LMichel L Posts: 141
    edited 2013-01-05 05:24
    After I had trouble with the sound I commented out these lines and continued with the rest of the game logic.

    So it's possible that the sound part doesn't work anymore.
  • Ahle2Ahle2 Posts: 1,179
    edited 2013-01-05 05:46
    Now we can be certain that Retronitus isn't the fault, so you will have to find out what the real issue is.
    Good luck!

    /Johannes
Sign In or Register to comment.