- View New Content
-
Getting Started
-
Tutorials
Tutorial Categories
Tutorials Main Page Installation and Setup Downloadable TutorialsROM Adjustments
Number of Balls Adjustments Volume Adjustments
-
Visual Pinball Tables
VP 8 Desktop Tables
All VPM Recreations VP Recreations VP/VPM MODs VP Originals ROMsVP 9 Desktop Tables
All VPM Recreations VP Recreations VP/VPM MODs VP Originals ROMsVP9 Cabinet Tables
All Full Screen Cabinet Full Screen B2S Cabinet Spanned Cabinet Tables Media Packs ROMsVPX Tables
All VPinMAME Recreations VPX- - /VPinMAME - MOD Tables VPX Recreations VPX Originals Media Packs ROMs VR
-
Frontend Media & Backglass
Media Packs
Complete Media Packs Wheel Logos VideosBackglasses
dB2S Animated Backglasses UVP Animated Backglasses Topper Images
- Future Pinball Tables
-
Design Resources
Main Resources
Table Templates Playfield Images Image Library Sound Library Key CodesVP Guides
VP8 Guide - English VP8 Guide - Deutsch VP9 Guide - English VP9.1.x Guide - English VP Object Guide VPM DocumentationFuture Pinball Resources
Playfield Images 3D Model LibraryFuture Pinball Guides
FP Script Guide Big Draco Script Guide FP Table Design Guide FP DMD Guide
- Other Features
- Bug Tracker
- Image Gallery
- Blogs
- More
Adding music (mp3's) to a table?
Started By
jdsabin1
, Apr 01 2011 02:27 PM
32 replies to this topic
#1
Posted 01 April 2011 - 02:27 PM
Everyone - JP added some very fun mp3's to a few older tables (fast draw and el dorado) and IMHO it makes the gameplay a real hoot to play. How hard is it to do this in other tables? I was thinking I'd love to do this to a table like KISS for example so along with the rudimentary midi sounds you could get some classic KISS songs playing as well.
Just curious as to how difficult this might be is all.
Thanks.
Just curious as to how difficult this might be is all.
Thanks.
'The ball is wild!' - Harry Williams
#2
Posted 01 April 2011 - 02:53 PM
all yas' gotta' do is put the mp3's into a music folder labeled 'music; then when we get the pin we know to also look for the music folder for it. the vp engine will call out for the music in game with the proper coding. it is not hard just needs that extra folder which many of us find annoying but it makes for the pin size to be lessened tremendously if you keep the music out of it. I have this current wip that is over 80 megs all due to the songs in it, if the music were in a separate folder the pin size would be only around 12 megs! that is the difference in sheer size due to the music files (usally I record in mono but with this pin I needed them in stereo greatly expanding their file size from around 4 mgs mono to about 12 megs stereo!
but again I like the music in the pin as it's a simpler download and I have yet to code a mp3 file into one.
but again I like the music in the pin as it's a simpler download and I have yet to code a mp3 file into one.
"Don’t let the noise of others’ opinions drown out your own inner voice.
And most important, have the courage to follow your heart and intuition.”
----Steve Jobs
And most important, have the courage to follow your heart and intuition.”
----Steve Jobs
#4
Posted 01 April 2011 - 04:41 PM
Here's how i have it in JP's KISS table,
'Start the music from Fast Draw table
MusicOn
End Sub
Sub table1_Paused:Controller.Pause = 1:End Sub
Sub table1_unPaused:Controller.Pause = 0:End Sub
Sub MusicOn
Dim x
x = INT(5 * RND(1) )
Select Case x
Case 0:PlayMusic "I Wanna Rock & Roll All Night.mp3"
Case 1:PlayMusic "I Was Made For Loving You.mp3"
Case 2:PlayMusic "Lick It Up.mp3"
Case 3:PlayMusic "Shout It Out Loud.mp3"
Case 4:PlayMusic "Russian Roulette.mp3"
Case 5:PlayMusic "Crazy Crazy Nights.mp3"
Case 6:PlayMusic "Psycho Circus.mp3"
Case 7:PlayMusic "Reason To Live.mp3"
End Select
End Sub
Sub Table1_MusicDone()
MusicOn
End Sub
'Start the music from Fast Draw table
MusicOn
End Sub
Sub table1_Paused:Controller.Pause = 1:End Sub
Sub table1_unPaused:Controller.Pause = 0:End Sub
Sub MusicOn
Dim x
x = INT(5 * RND(1) )
Select Case x
Case 0:PlayMusic "I Wanna Rock & Roll All Night.mp3"
Case 1:PlayMusic "I Was Made For Loving You.mp3"
Case 2:PlayMusic "Lick It Up.mp3"
Case 3:PlayMusic "Shout It Out Loud.mp3"
Case 4:PlayMusic "Russian Roulette.mp3"
Case 5:PlayMusic "Crazy Crazy Nights.mp3"
Case 6:PlayMusic "Psycho Circus.mp3"
Case 7:PlayMusic "Reason To Live.mp3"
End Select
End Sub
Sub Table1_MusicDone()
MusicOn
End Sub
#6
Posted 11 June 2011 - 03:56 AM
QUOTE (clyde @ Apr 1 2011, 12:41 PM) <{POST_SNAPBACK}>
Here's how i have it in JP's KISS table,
'Start the music from Fast Draw table
MusicOn
End Sub
Sub table1_Paused:Controller.Pause = 1:End Sub
Sub table1_unPaused:Controller.Pause = 0:End Sub
Sub MusicOn
Dim x
x = INT(5 * RND(1) )
Select Case x
Case 0:PlayMusic "I Wanna Rock & Roll All Night.mp3"
Case 1:PlayMusic "I Was Made For Loving You.mp3"
Case 2:PlayMusic "Lick It Up.mp3"
Case 3:PlayMusic "Shout It Out Loud.mp3"
Case 4:PlayMusic "Russian Roulette.mp3"
Case 5:PlayMusic "Crazy Crazy Nights.mp3"
Case 6:PlayMusic "Psycho Circus.mp3"
Case 7:PlayMusic "Reason To Live.mp3"
End Select
End Sub
Sub Table1_MusicDone()
MusicOn
End Sub
'Start the music from Fast Draw table
MusicOn
End Sub
Sub table1_Paused:Controller.Pause = 1:End Sub
Sub table1_unPaused:Controller.Pause = 0:End Sub
Sub MusicOn
Dim x
x = INT(5 * RND(1) )
Select Case x
Case 0:PlayMusic "I Wanna Rock & Roll All Night.mp3"
Case 1:PlayMusic "I Was Made For Loving You.mp3"
Case 2:PlayMusic "Lick It Up.mp3"
Case 3:PlayMusic "Shout It Out Loud.mp3"
Case 4:PlayMusic "Russian Roulette.mp3"
Case 5:PlayMusic "Crazy Crazy Nights.mp3"
Case 6:PlayMusic "Psycho Circus.mp3"
Case 7:PlayMusic "Reason To Live.mp3"
End Select
End Sub
Sub Table1_MusicDone()
MusicOn
End Sub
is there a certain spot in the script? also where do the mp3's need to be stored table folder?
#7
Posted 11 June 2011 - 10:45 AM
um I think that code is for a song to play randomly: x = INT(5 * RND(1) ) I think this means it'll pick a song randomly out of the list hence the: select case x line where x is any one of them and it usually goes into where everything else gets 'dimmed' at the top of the script
again Do not quote me here as I have yet to put any mp3's into my wip's I stick with wav. files this way I know the person getting the table gets the music since wav.'s are written into the script and mp3's are in an external folder (the music folder in your vp folder)
this is not tech support just MY PERSONAL OPINION just making this clear
again Do not quote me here as I have yet to put any mp3's into my wip's I stick with wav. files this way I know the person getting the table gets the music since wav.'s are written into the script and mp3's are in an external folder (the music folder in your vp folder)
this is not tech support just MY PERSONAL OPINION just making this clear
Edited by faralos, 11 June 2011 - 10:46 AM.
"Don’t let the noise of others’ opinions drown out your own inner voice.
And most important, have the courage to follow your heart and intuition.”
----Steve Jobs
And most important, have the courage to follow your heart and intuition.”
----Steve Jobs
#9
Posted 11 June 2011 - 01:22 PM
Put the .mp3 files in the Visual Pinball\Music folder.
Then in the script add:
PlayMusic "NameOfFile.mp3"
You can put this in a Sub for a Bumper_Hit() or inside of an If/Then statement when the points reach a certain score, or Extra Ball, etc., just about anywhere, but best to put the line inside of a Sub on an event like Bumper_Hit, Kicker_Hit, etc.
Use EndMusic() to stop.
Then in the script add:
PlayMusic "NameOfFile.mp3"
You can put this in a Sub for a Bumper_Hit() or inside of an If/Then statement when the points reach a certain score, or Extra Ball, etc., just about anywhere, but best to put the line inside of a Sub on an event like Bumper_Hit, Kicker_Hit, etc.
Use EndMusic() to stop.
#10
Posted 11 June 2011 - 03:07 PM
QUOTE (clyde @ Apr 1 2011, 12:41 PM) <{POST_SNAPBACK}>
Here's how i have it in JP's KISS table,
'Start the music from Fast Draw table
MusicOn
End Sub
Sub table1_Paused:Controller.Pause = 1:End Sub
Sub table1_unPaused:Controller.Pause = 0:End Sub
Sub MusicOn
Dim x
x = INT(5 * RND(1) )
Select Case x
Case 0:PlayMusic "I Wanna Rock & Roll All Night.mp3"
Case 1:PlayMusic "I Was Made For Loving You.mp3"
Case 2:PlayMusic "Lick It Up.mp3"
Case 3:PlayMusic "Shout It Out Loud.mp3"
Case 4:PlayMusic "Russian Roulette.mp3"
Case 5:PlayMusic "Crazy Crazy Nights.mp3"
Case 6:PlayMusic "Psycho Circus.mp3"
Case 7:PlayMusic "Reason To Live.mp3"
End Select
End Sub
Sub Table1_MusicDone()
MusicOn
End Sub
'Start the music from Fast Draw table
MusicOn
End Sub
Sub table1_Paused:Controller.Pause = 1:End Sub
Sub table1_unPaused:Controller.Pause = 0:End Sub
Sub MusicOn
Dim x
x = INT(5 * RND(1) )
Select Case x
Case 0:PlayMusic "I Wanna Rock & Roll All Night.mp3"
Case 1:PlayMusic "I Was Made For Loving You.mp3"
Case 2:PlayMusic "Lick It Up.mp3"
Case 3:PlayMusic "Shout It Out Loud.mp3"
Case 4:PlayMusic "Russian Roulette.mp3"
Case 5:PlayMusic "Crazy Crazy Nights.mp3"
Case 6:PlayMusic "Psycho Circus.mp3"
Case 7:PlayMusic "Reason To Live.mp3"
End Select
End Sub
Sub Table1_MusicDone()
MusicOn
End Sub
In this example the random number generated will only be 1 through 5, so it will never play Psycho Circus.mp3 or Reason To Live.mp3
You have discovered an Easter egg. Pat yourself on the back.
#11
Posted 11 June 2011 - 03:54 PM
QUOTE (sleepy @ Jun 11 2011, 09:22 AM) <{POST_SNAPBACK}>
Put the .mp3 files in the Visual Pinball\Music folder.
Then in the script add:
PlayMusic "NameOfFile.mp3"
You can put this in a Sub for a Bumper_Hit() or inside of an If/Then statement when the points reach a certain score, or Extra Ball, etc., just about anywhere, but best to put the line inside of a Sub on an event like Bumper_Hit, Kicker_Hit, etc.
Use EndMusic() to stop.
Then in the script add:
PlayMusic "NameOfFile.mp3"
You can put this in a Sub for a Bumper_Hit() or inside of an If/Then statement when the points reach a certain score, or Extra Ball, etc., just about anywhere, but best to put the line inside of a Sub on an event like Bumper_Hit, Kicker_Hit, etc.
Use EndMusic() to stop.
sweet...thanks will try later today!!
#15
Posted 09 June 2020 - 03:52 AM
The playmusic command has no volume parameters. So for now you'll need to change the volume as Greynurse said, using an audio editor.
But in VPX 10.7 you'll be able to add the mp3 songs directly in the editor and play them with the PlaySound command It is working now in the beta, but the volume is way too high, toxie is working with it (this is why it is "beta")
These are my tables, sorted by date, all them playable with VPX 7 or newer:
After 18 years making tables, it is time to take a rest and let new authors do their thing.
I guess at last I'll play some more pinball . But I'm sure I'll make some table updates from time to time
#16
Posted 07 November 2020 - 04:59 PM
Easily Add Music To Any Table
Here's a function to add music to a table, you just need the directory name. No need to number songs or call them out in the script. Songs are played randomly. You can add new songs to the directory and they will be picked up automatically.
Once the table script is updated and the table started. A song can be started or can be switched to next song by clicking the Right Magna key. The music can be stopped by clicking the Let Magna key
Here's the script, just paste it below any End Sub command. Then change the text in red to the name of the directory that has your mp3 files (ogg files do not work). It must be a child folder of the Visual Pinball\music folder (for example C:\Visual Pinball\Music\AltCountryWestern)
Sub MusicOn
Dim FileSystemObject, folder, r, ct, file, musicPath, myMusicFolder
myMusicFolder = "AltCountryWestern" ' the directory name where your mp3 files are storied, must be a subfolder of Visual Pinball\music
Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
musicPath = FileSystemObject.GetAbsolutePathName(".") ' get path to Visual Pinball\table
musicPath = Left(musicPath, Len(musicPath) - 6) + "music\" 'get path to Visual Pinball\music
Set folder = FileSystemObject.GetFolder(musicPath + myMusicFolder)
Randomize
r = INT(folder.Files.Count * Rnd + 1)
ct=1
For Each file in folder.Files 'get every file in myMusicFolder, for each one count it and see if the count matches the random number
if ct = r Then ' random file found
if (LCase(Right(file,4))) = ".mp3" Then ' can only play mp3 files
PlayMusic Mid(file, Len(musicPath) + 1, 1000) ' PlayMusic defaults to Visual Pinball\music\, need to get myMusicFolder\song name
End If
End If
ct = ct + 1
Next
End Sub
Sub Table1_MusicDone() 'may not be called Table1
MusicOn
End Sub
The only other thing you need to do is add the commands to catch the right and left Magna Keys in the KeyDown function. Add the lines in red
Sub Table1_KeyDown(ByVal keycode) 'may not be called Table1
If keycode = RightMagnaSave Then MusicOn
If keycode = LeftMagnaSave Then EndMusic
MusicOn can also be put in the Table1_Init sub to start music when the table starts
Make sure you save your changed (File/Save)
Edited by jogrady7, 01 February 2021 - 06:00 PM.
#17
Posted 30 April 2022 - 08:44 PM
cannot figure this out, is this correct?
End Sub
Sub MusicOn
Dim FileSystemObject, folder, r, ct, file, musicPath, myMusicFolder
myMusicFolder = "ownmusic" ' the directory name where your mp3 files are storied, must be a subfolder of Visual Pinball\music
Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
musicPath = FileSystemObject.GetAbsolutePathName(".") ' get path to Visual Pinball\table
musicPath = Left(musicPath, Len(musicPath) - 6) + "music\" 'get path to Visual Pinball\music
Set folder = FileSystemObject.GetFolder(musicPath + myMusicFolder)
Randomize
r = INT(folder.Files.Count * Rnd + 1)
ct=1
For Each file in folder.Files 'get every file in myMusicFolder, for each one count it and see if the count matches the random number
if ct = r Then ' random file found
if (LCase(Right(file,4))) = ".mp3" Then ' can only play mp3 files
PlayMusic Mid(file, Len(musicPath) + 1, 1000) ' PlayMusic defaults to Visual Pinball\music\, need to get myMusicFolder\song name
End If
End If
ct = ct + 1
Next
End Sub
Sub Table1_MusicDone() 'may not be called Table1
MusicOn
End Sub
#18
Posted 29 June 2022 - 07:27 AM
cannot figure this out, is this correct?
...
That is correct (from what I can see), but you need to make sure you add the commands in for the magna save buttons. The way I did it was to go into the script, then CTRL+F and do a search for "Keydown", and that takes me to the correct spot (as Jogrady7 shows).
Then, as long as the table is called table1, add in the two red lines from Jogrady7's post.
For example, this is what mine for my Iron Maiden 1981 table looks like:
Sub table1_KeyDown(ByVal Keycode)
If keycode = LeftTiltKey Then Nudge 90, 5:PlaySound SoundFX("fx_nudge", 0), 0, 1, -0.1, 0.25
If keycode = RightTiltKey Then Nudge 270, 5:PlaySound SoundFX("fx_nudge", 0), 0, 1, 0.1, 0.25
If keycode = CenterTiltKey Then Nudge 0, 6:PlaySound SoundFX("fx_nudge", 0), 0, 1, 0, 0.25
If vpmKeyDown(keycode)Then Exit Sub
If keycode = PlungerKey Then PlaySoundat "fx_PlungerPull",Plunger:Plunger.Pullback
If keycode = RightMagnaSave Then MusicOn
If keycode = LeftMagnaSave Then EndMusic
'If keycode = KeyRules Then Rules
End Sub
If you didn't do that bit then you can't get the music to start using the magna save buttons.
Jogrady7's script works great for me; but I notice it doesn't automatically run the random select process at the end of a song (at least not for me); is it supposed to?
Or, anyone know the script to add to to what jogrady7 posted that would make it choose another track at the end of each track? A bit annoying that I have to hit the magnasave button each time a song finishes.
Or have I done something wrong?
#20
Posted 30 June 2022 - 10:49 AM
Legend, thanks Roadblock!
To anyone playing at home, the thread Roadblock pointed me to talks about the script for Playboy 1978 which I have, and it didn't click that that table was going to next track ok (d'oh); anyhoo, long story short, I ;poked around and worked out that if you add the following sub right after Jogrady7's script above, you'll get it to run the random routine again after each track.... it does mean though that sometimes you'll get the same song playing again, but this depends on how much music you jam into the folder you point it to.
---------
Sub Table1_MusicDone
MusicOn
End Sub
-----------
Enjoy (and I'm new so I'm sorry if this is breaking any forum rules).