Coding Jump Drive sound

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
Frantic
Competent
Competent
Posts: 41
Joined: Sun Mar 26, 2006 1:41 pm
Location: Brno
Contact:

Coding Jump Drive sound

Post by Frantic »

Am adding Jump Drive sound from Amiga Elite amongst other things. I have a sound file 9 seconds long recorded from winuae of a jump drive in action, with a fade out editted in (probably won't use this bit). Wired this in and the sound file plays on queue, and stops on queue with J key.

Ok, now the tricky bit. I need to make it a repeating sound like the loopafterburnersound code, but I need to ensure that the first 4 seconds of the sound plays uninterrupted (unless user cancells), and then have second sound file(s) play the repeating sound.

How can I determine how much time has passed from my initial triggering of the sound, so that I can tell my sound loop when to override and kick in? I can do the logic easily, but I need to know how to A) grab the time and B) store it in a globally accessible variable or pass it on to a function in PlayerEntity.m

Thanks in advance, I've spent my programming career building business systems and haven't rtfm yet :-)
User avatar
winston
Pirate
Pirate
Posts: 731
Joined: Mon Sep 27, 2004 10:21 pm
Location: Port St. Mary, Isle of Man
Contact:

Post by winston »

OK - what you probably need to do is this (Oolite doesn't really have sound looping code as such - but this is the way it's done at the moment)

What you'll need is this - a 4 second long sound that gets started when the player presses 'j' to start the jump drive, and then another sound to be the loop (and decay) part of the sound.

Create a new function 'loopJumpdriveSound'. Model it after the loopAfterburnerSound in PlayerEntity.m. What you'll need to do is set the delay on performSelector to 4 seconds for the first time around, then 1.25 seconds (or whatever) on subsequent calls (you can make the decision on what you set the delay to based on whether the instance variable (which you'll need to create) 'hyperspeedSoundLooping' is set). There already is an instance variable 'hyperspeed_engaged' which you can check to see if they hyperspeed is still engaged.

Oh by the way, to get started with Objective-C, a selection of websites that may help:

http://www.gnustep.org/developers/documentation.html - GNUstep's documentation, including some mini-tutorials
http://www.toodarkpark.org/computers/objc/ - looks like a manual
Frantic
Competent
Competent
Posts: 41
Joined: Sun Mar 26, 2006 1:41 pm
Location: Brno
Contact:

Post by Frantic »

Thanks for all that. Managed to get it all working fairly smoothly. Having loops set to trigger after cancelling the jump had to be dealt with. Hammering the J key repeatedly etc.

Lost internet yesterday, so spent some more time tinkering with sounds. Have rigged everything so there is no change to the vanilla version, changes only become apparent as you install extra sound files.

I'd really like to get someone to look over my noob coding and tell me what I did utterly wrong. I played my save files using the compiled result for several jumps and it all seems to work fine. I'd really like to get this integrated into the main trunk, so I can release a new Amiga sound pack :-)

A list of stuff:

- Jump sound
- Scoop sound upon actual scooping of cargo (works alongside the tractor sound)
- Launching, docking and hyperspace are now 3 different sound files. If the 2 extra sound files (or just one of them) aren't installed, it defaults them to breakpattern.ogg
- Added a repeating warning sound for persistent dangers such as cabin high temperature, low energy, and low altitude.
Post Reply