playSFX(which channel, which folder, clip0, clip1, priority)

From pinHeck Wiki
Jump to: navigation, search


Example:

playSFX(0, 'B', 'A', 'A', 255);

Plays audio file "BAA.wav" from the SFX/_FB folder on Channel 0 at top Priority.


Use channels 0-2. Channel 3 is reversed for music (usually always playing)

If a sound file is currently playing on Channel 0 at a higher priority than an incoming sound, then the new sound will not play. What I tend to do is use channel 0 for voice prompts, channel 1 for mid-table sound effects (targets, slings etc) and channel 2 for back of the table sounds (pop bumpers and rollovers) This helps "space out" the sounds during a multiball.

As an example, run your normal pop bumper sound on channel 2 with a priority of 250. Then, if you have a "Super Pops" sound or callout, use the same channel but with a priority of 255. Reason for this is let's say you get 50 pops and it says "SUPER POPS!" Now you'll probably get additional pop hits while this voice plays. By calling the voice at 255, and the pops at 250, it ensures the normal pop sound won't override the voice prompt until the priority 255 voice prompt finishes.

It might be tempting to avoid this by using different channels all the time, but the problem there is you may have voices overlapping which sounds bad.

The 3 characters must be valid ASCII filename characters, and the first character MUST be A-Y (to match the folders). The sound data is subdivided into folders to greatly reduce search time (worst case is 5ms, usually less)

You CAN however mix and match variables to create randomized or progress-based callouts. For example:

playSFX(0, 'M', 'D', '0' + random(4), 255);

Will randomly pick from:

MD0.wav

MD1.wav

MD2.wav

MD3.wav

What is does is takes the ASCII value of '0' (48) and adds a random number between 0 and 3 to it. Or you could also do this:

playSFXQ(0, 'M', 'D', '@' + progress, 255);

Progress variable would increase every time you make a shot, so the clips could be labeled:

MDA.wav

MDB.wav

MDC.wav

MDD.wav

Notice how we start with '@' (64) and then add Progress? That's because making the shot increments Progress by 1, so it will never be 0. 64+1=65 which is the letter A.

AMH took this a bit further with code like:

playSFX(0, 'L', 48 + hotProgress[player], random(4) + 65, 255);

So for each shot that advances the Hotel, there are 4 random phrases per shot.

L1A.wav -Four different voices for Shot 1

L1B.wav

L1C.wav

L1D.wav

L2A.wav -Four different voices for Shot 2, and so on

L2B.wav

L2C.wav

L2D.wav


Techniques like these can greatly randomize your audio and keep it fresh every time!