FP Clever Way to Code Background Music on Future Pinball

Future Pinball

GeorgeH

Flippered Out
Site Supporters
Joined
May 3, 2016
Messages
3,114
Solutions
7
Reaction score
2,480
Points
145
Favorite Pinball Machine
Attack From Mars
I've been modifying some of Roney Pinball's tables, and I wanted to share something clever I discovered in his scripting. If you've ever looked at his code, you'll notice he has an ingenious method for handling background music.

To start using his approach, add the following line of code inside Sub FuturePinball_BeginPlay():

Code:
MusicChannelInUse = 0

When you want to play a specific background music track, simply call PlayMusicForMode(1), PlayMusicForMode(2), or PlayMusicForMode(3). There's no need to manually stop the current track — it's handled automatically. Just insert the PlayMusicForMode() call wherever you'd like the music to begin. If you have more than three music tracks, you can easily add more cases to the script. To stop the music entirely, call PlayMusicForMode(0). It also simplifies sound level adjustments, since all the background music is centralized in a single subroutine.

This method might be useful on tables where you're running short on available music channels. It only uses two channels for all background music. However, keep in mind that this method isn't suitable for effects like ball rolling sounds, since those need to play simultaneously with background music. Even so, this approach can help you free up music channels for other uses.

Here’s the main code, which is fairly straightforward:

Code:
Sub PlayMusicForMode(Mode)
    If (CurrentMusicTunePlaying <> Mode) Then
        Dim ThisChannel, NextChannel
        If (MusicChannelInUse = 1) Then
            ThisChannel = 1
            NextChannel = 2
            MusicChannelInUse = 2
        Else
            MusicChannelInUse = 1
            ThisChannel = 1
            NextChannel = 2
        End If
        Select Case (Mode)
            Case 0:        EffectMusic ThisChannel, FadeOutAndStop, 0.0, 1000
                            EffectMusic NextChannel, FadeOutAndStop, 0.0, 1000
            Case 1:        PlayMusic    NextChannel, "InGame_Theme", True, 1
                            EffectMusic NextChannel, PlayAndFadeIn,  1.0, 1000
                            EffectMusic ThisChannel, FadeOutAndStop, 0.0, 1000
            Case 2:        PlayMusic    NextChannel, "Attract_Mode_Theme", False, 1
                            EffectMusic NextChannel, PlayAndFadeIn,  1.0, 1000
                            EffectMusic ThisChannel, FadeOutAndStop, 0.0, 1000
            Case 3:        PlayMusic    NextChannel, "Multiball_Theme", false, 1
                            EffectMusic NextChannel, PlayAndFadeIn,  1.0, 1000
                            EffectMusic ThisChannel, FadeOutAndStop, 0.0, 1000
       End Select
        CurrentMusicTunePlaying = Mode
    End If
End Sub
 
Last edited:
General chit-chat
Help Users
You can interact with the ChatGPT Bot in any Chat Room and there is a dedicated room. The command is /ai followed by a space and then your ? or inquiry.
ie: /ai What is a EM Pinball Machine?
  • No one is chatting at the moment.
  • Chat Bot Mibs Chat Bot Mibs:
    scutters has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    vincez28 has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    rocker has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    unomismo has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    Gamegod2x has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    DocRazor has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    ejrcooney has joined the room.
  • E @ ejrcooney:
    B2S server.exe Version 2.5.0.320 How can you make the B2SDMD stay on Visible. Make it the default instead of hidden. Did new install of 10.8 final have many tables I would have to open to change to visible instead of hidden. Any help would be much appreciated.
    Quote
  • xenonph @ xenonph:
    @ejrcooney Try right clicking on backglass with mouse pointer, and you should see B2S DMD Visibility setting at top of window.
    Quote
  • E @ ejrcooney:
    Want to make visible the default. Right now it is set on hidden.
    Quote
  • Quote
  • xenonph @ xenonph:
    I sent you message with pic showing where to make visible adjustment.
    Quote
  • Chat Bot Mibs Chat Bot Mibs:
    Pinped has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    daleks12 has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    Stephen has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    docdoc has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    Exnihilo_Mundus has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    angmarg52 has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    tully619 has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    smorndb has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    Tech49 has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    Topsi Klaus has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    Forsaken43 has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    duduky72 has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    Gerge has left the room.
      Chat Bot Mibs Chat Bot Mibs: Gerge has left the room.
      Back
      Top