Greetings all,
Let me start off by saying 'thank you' to all the VPX tables makers and scripting gurus here.
This is probably very basic scripting to most seasoned builders, but for me, it was a huge step because I am a basic 'noob' when it comes to table creation and scripting. Other than changing options provided by some table makers at the top of some table scripts, I know nothing about scripting at all, which is why I was really pleased when I got the following to work.
- - - - - - - - - - - - - - - - - - - - - - - - -
On some older tables, especially music themed ones, I wanted to add background mp3 music playing while pinballing. Now some table makers add music options to tables and sometimes add the music option to newer releases, but many times the mp3 music track would start playing when the ball was pushed into the plunger lane, or when the ball was fired from the plunger. Usually the mp3 audio track would abruptly END when the ball drained (lost ball) and then the next music track would start when the next ball is played.
This is all good and one some tables this is fine, but if you are having a sucky day and not playing pinball well that day, you only hear the first 15-20 seconds of a song and then it ends because you have lost the ball (drained) and you don't get into a 'rhythm' of playing out the song in its entirety ... which can be very frustrating.
Some newer Stern tables like Metallica or AC/DC give you the option of selecting a single song when gameplay is started and then has loop portions of the song and the song progresses as you play, which is a nice feature. Those particular tables, and others, allow you to change the music track mid-play, which is also nice.
But for older 70s and 80s tables, the ROM sounds are pretty basic.
So, I was on a mission ...
I wanted to share a script I managed to cobble together / write / get to work for use in some of my older style "music themed" tables like Kiss (Bally), Rolling Stones (Bally) and even Playboy (Bally) - 70s disco theme, using the 'built in mp3 player in VPX.
I wanted the music / audio to 'enhance' the gameplay, and not overpower it or completely replace the ROM sound and never go back. I wanted something I could turn on and off at my leisure and also keep the original game intact.
Here's what I did.
- - - - - - - - - - - - - - - - - - - - - - - - -
Open the script window for the table you want to add music / audio to and do a script search for: "Sub Table1_KeyDown"
Search show returns a line somewhere near the top of the script code that read:
Sub Table1_KeyDown(ByVal keycode)
Insert these (2) lines immediately after the Sub Table1_KeyDown(ByVal keycode) line
If KeyCode = RightMagnaSave Then NextTrack If KeyCode = LeftMagnaSave Then EndMusic
So your addition should look like this:
Sub Table1_KeyDown(ByVal keycode) If KeyCode = RightMagnaSave Then NextTrack If KeyCode = LeftMagnaSave Then EndMusic
Now, a little further down, somewhere in-between some of the other subroutines in the script, cut and paste / add the following lines:
'****************************** '* HiRez00: Music Mod * '****************************** Dim musicNum Sub NextTrack If musicNum = 0 Then PlayMusic "YourMusicTrack.mp3" End If If musicNum = 1 Then PlayMusic "YourMusicTrack.mp3" End If If musicNum = 2 Then PlayMusic "YourMusicTrack.mp3" End If If musicNum = 3 Then PlayMusic "YourMusicTrack.mp3" End If If musicNum = 4 Then PlayMusic "YourMusicTrack.mp3" End If If musicNum = 5 Then PlayMusic "YourMusicTrack.mp3" End If If musicNum = 6 Then PlayMusic "YourMusicTrack.mp3" End If If musicNum = 7 Then PlayMusic "YourMusicTrack.mp3" End If If musicNum = 8 Then PlayMusic "YourMusicTrack.mp3" End If If musicNum = 9 Then PlayMusic "YourMusicTrack.mp3" End If musicNum = (musicNum + 1) mod 10 End Sub Sub Table1_MusicDone NextTrack End Sub '***************************** '* End Music Mod * '*****************************
Keep all the 'apostrophes" and other lines intact. Simply change the YourMusicTrack.mp3 in each line to the song / music file name you are using. i.e.: My Cool Music.mp3 or Lick it Up.mp3 - etc.
You can add as many audio tracks and 'If musicNum = x Then PlayMusic ..." lines as you like, just make sure to change the musicNum number as you go.
Then in the "musicNum = (musicNum + 1) mod 10" line, change the 10 number to 1 number higher than the 'If musicNum; lines or the total number of tracks you are adding. Remember you start a 0 at the top of the script, so the number is 1 higher than the 'If musicNum' line. Hope this makes sense.
Add all your mp3 music files to the "Music" folder in Visual Pinball - then - and this is important ... go to the "Music" folder. Select all your mp3 music files and RIGHT CLICK on them go to properties, then select details. You want to 'Remove all Additional Data' from the music files i.e.: artists, album, track number etc because this is the additional data that is stored in the 'IDE' of the mp3 files that sometimes messes with the mp3 playback engine in VPX. When you remove all this additional data, the files will play in VPX with no problem.
Save your table and script changes, then start up the table.
Remember, the music will not automatically start, you need to press the RIGHT MagnaSave button for the music to start. I did it this way so I can still play the table with all the original chimes and sounds without any music if I wanted to ... call me nostalgic.
If you press the RIGHT MagnaSave button again, the player will automatically jump to the next music track.
You can let the music play and NOT press the Right MagnaSave and when the audio track ends, it will automatically jump to the next one. When it gets to the end of all your music tracks, it will automatically start track 1 again, etc.
If you press the LEFT MagnaSave button, the player will STOP all music. You can press the RIGHT MagnaSave button to resume playing your music tracks.
If the sounds and chimes from the original table ROMS are overpowering your music, press the F12 button to adjust the ROM volumes so you have a nice balance of ROM sound and your music. These changes are automatically saved in the registry file so you will have the same settings for this particular ROM the next time you play a table that uses it.
- - - - - - - - - - - - - - - - - -
Like I said, this is really basic scripting. But I think other 'inexperienced' VPX users would learn something from my efforts.
Hope you find this script and tutorial interesting, helpful and useful.
Edited by HiRez00, 12 April 2020 - 04:13 PM.