Author Topic: Background (Ambient) Music Sounds Random Selection ?  (Read 1550 times)

matchiz

  • Newbie
  • *
  • Posts: 2
    • View Profile
Background (Ambient) Music Sounds Random Selection ?
« on: November 23, 2020, 03:11:58 PM »
Hello,

I have searched through this forum and have come to a dead end. I am hoping to either find a script or an option to enable that will allow attract mode to choose from a folder of music options.

I know there is an option of choosing a single audio file, but I would like that single audio file to be random.

hermine.potter

  • Hero Member
  • *****
  • Posts: 767
    • View Profile
Re: Background (Ambient) Music Sounds Random Selection ?
« Reply #1 on: November 25, 2020, 03:26:47 AM »
the problem is, that attract.exe blocks that file.
so you can't change it on the fly, if attract.exe is running (idea was to change that file after a few seconds via external software (batch, autoit, AHK,.. in background/besides attract)

I don't have a attractmode integrated solution.
but this quick and dirty solution via external software like autoit:

start this autoit script along with attract.exe:
Code: [Select]
#include <file.au3>

while 1

$sourceFolder = "C:\attract\sounds"
$aFileList = _FileListToArray($sourceFolder, "*.mp3", 1)
$iRandom = Random(1,$aFileList[0],1)

If ProcessExists ("vlc.exe") Then
sleep(100)

if ProcessExists ("mame.exe") Then
ProcessClose("vlc.exe")
EndIf

If ProcessExists ("notepad.exe") Then
ProcessClose("vlc.exe")
EndIf

Else
run ('C:\Program Files\VideoLAN\VLC\vlc.exe --quiet --qt-start-minimized --play-and-exit ' & $sourceFolder & "\" & $aFileList[$iRandom] & ' vlc://quit')
EndIf

WEnd

-disable Windows Popup VLC Notification in vlc.exe : Here
-script choose a random .mp3 file from a specific folder (here : C:\attract\sounds )
-when song ends, next random .mp3 starts
-sound playing stops, if Editor/notepad.exe or Mame/mame.exe starts
AM Version : 2.6.1
Input : Mad Catz Brawlstick; Mouse; Keyboard; Xbox360 Wireless
Cabinet : Yes
OS : Windows10 Pro
System : Dell Precision T3500 ; Intel X5650 ; 12GB RAM