Custom Radio Station Program

Hi there,
because a lot of people (me included) had some trouble with custom radio stations, I wrote this little script for playing your own music without minimizing the game or replacing the ingame songs.

The program is written in Autoit, so if you don't trust .exe files a random user uploaded with his first post, you can copy and paste the source code into an autoit script file and compile it (see http://www.autoitscript.com/site/autoit/ )

Ho to use:
1. Extract the .zip anywhere on your computer
2. create at this location some folder (your radio stations) and place your music files inside them
3. execute the program, assign the hotkeys or leave them blank if you don't need the feature.
4. Hit „start“ and have fun^^
5. If you want to exit the program, right click the little Radio.exe icon in the taskbar and close it

I strongly recommend to use your "jump-out-of-your-car" key to stop the music, so the music will pause when you exit a vehicle, if you want to turn the radio on, press you next/previous station key.
if you want to use the same keys as in Saints Row, you should set your ingame music volume to 0
if you find bugs, errors or have questions or feature requests, don't hesitate to comment
I tried to display the current station/song, but until now I couldn't find a solution

Known issues:
-if some mp3 songs aren't playing,the reason is most likely the cover-art. you can easily remove them (I use this one, other programs should work too http://www.chip.de/downloads/TagScanner_13010651.html ); (detailed instruction below)
-I'm not sure which file types are fully supported, but at least my mp3, wav and wma files are working fine
-if a radio station isn't working, make sure to have at least 2 files in each one, otherwise they won't work
-subfolders won't be recognized

How to Remove the mp3 Art
0. Place alle files in their radio stations
1. drag&drop all folders in the main window and press ctrl+a or mark all songs
2. klick on „tag-editor“ in the headline
3. scroll at the right side down until you see the headline „Embedded Art“ and hit the „clear field“ button
4. save your files
see the pictrue for more help

edit:
Added Hotkey-Funktion to exit program; f1-f12 and esc should now be recognized too
Code:
#cs ----------------------------------------------------------------------------
 
AutoIt Version: 3.3.8.1
Author:        Inori
http://www.saintsrowmods.com/forum/index.php?members/inori.35006/
 
Script Function:
    Custom Radio Station Program
 
#ce ----------------------------------------------------------------------------
 
#include <GUIConstantsEx.au3>
#include <GuiButton.au3>
#include <Misc.au3>
#include <file.au3>
#include <array.au3>
#include <WindowsConstants.au3>
#include <Sound.au3>
#include <WinAPI.au3>
$inst_path = (@ScriptDir & "\")
 
 
 
 
 
$label_width = 195
$label_height = 19
$xPos = 5
$xPos2 = $xPos + $label_width
$yPos = 5
$i = 0
$zeilen_counter = 1
$hotkey_next = 0
$sound = 0
;==============SettingsDiag============;
$standard = True
 
If FileExists("Settings.txt") Then $standard = False
While 1
    $gui = GUICreate("Main", 400, (8) * ($label_height + 1) + 10, -1, -1, BitOR($WS_POPUP, $WS_BORDER))
    Global $hotkey_exit = InputCreation("Hotkey - Exit the Program", "ESC")
    Global $hotkey_next = InputCreation("Hotkey - Next Radio Station", "c")
    Global $hotkey_previous = InputCreation("Hotkey - Previous Radio Station", "x")
    Global $hotkey_stop = InputCreation("Hotkey - Stop Music", "e")
    Global $hotkey_increase = InputCreation("Hotkey - Increase Radio Volume", "p")
    Global $hotkey_decrease = InputCreation("Hotkey - Decrease Radio Volume", "o")
    Global $volume = InputCreation("Standard Volume: 0-100", "50")
    ;global $ingame_title= CheckboxCreation("Show Song Title Ingame","False")
    Int($volume)
 
    $button = GUICtrlCreateButton("Start", $xPos, $yPos, $label_width * 2 / 3, $label_height)
    $button2 = GUICtrlCreateButton("Cancel", $xPos2 * 2 / 3 + $xPos * 2 / 3, $yPos, $label_width * 2 / 3, $label_height)
    $button3 = GUICtrlCreateButton("Reset", $xPos2 * 4 / 3 + $xPos * 2 / 3, $yPos, $label_width * 2 / 3, $label_height)
 
    GUISetState()
    While 1 * Sleep(50)
        $msg = GUIGetMsg()
        Select
 
            Case $msg = $button Or _IsPressed("0D");start
 
                FileDelete("Settings.txt")
                write($hotkey_exit);1
                write($hotkey_next)
                write($hotkey_previous)
                write($hotkey_stop)
                write($hotkey_increase)
                write($hotkey_decrease)
                write($volume)
                ;write($ingame_title)
                $hotkey_exit = guictrlread($hotkey_exit)
                if $hotkey_exit="f1" Then $hotkey_exit="{f1}"
                if $hotkey_exit="f2" Then $hotkey_exit="{f2}"
                if $hotkey_exit="f3" Then $hotkey_exit="{f3}"
                if $hotkey_exit="f4" Then $hotkey_exit="{f4}"
                if $hotkey_exit="f5" Then $hotkey_exit="{f5}"
                if $hotkey_exit="f6" Then $hotkey_exit="{f6}"
                if $hotkey_exit="f7" Then $hotkey_exit="{f7}"
                if $hotkey_exit="f8" Then $hotkey_exit="{f8}"
                if $hotkey_exit="f9" Then $hotkey_exit="{f9}"
                if $hotkey_exit="f10" Then $hotkey_exit="{f10}"
                if $hotkey_exit="f11" Then $hotkey_exit="{f11}"
                if $hotkey_exit="f12" Then $hotkey_exit="{f12}"
                if $hotkey_exit="esc" Then $hotkey_exit="{ESC}"
                $hotkey_next = hotkeys($hotkey_next)
                $hotkey_previous = hotkeys($hotkey_previous)
                $hotkey_stop = hotkeys($hotkey_stop)
                $hotkey_increase = hotkeys($hotkey_increase)
                $hotkey_decrease = hotkeys($hotkey_decrease)
                $volume = hotkeys($volume)
                ;$ingame_title= GUICtrlRead($ingame_title)
 
                GUIDelete()
                ExitLoop (2)
 
            Case $msg = $button2 ;Cancel
                Exit
 
            Case $msg = $button3 ;Reset
                $standard = True
                $label_width = 195
                $label_height = 19
                $xPos = 5
                $xPos2 = $xPos + $label_width
                $yPos = 5
                $i = 0
                $zeilen_counter = 1
                GUIDelete($gui)
                ExitLoop
        EndSelect
 
 
 
    WEnd
WEnd
 
;===================Radio=================;;
HotKeySet($hotkey_exit, "MainExit")
$Stations = _FileListToArray($inst_path, "*", 2)
 
$stations_count = $Stations[0]
ConsoleWrite($stations_count)
$current_station = 1
 
$playing = False
While 1 * Sleep(50)
    Select
        Case _IsPressed($hotkey_next)
            If $playing = False Then
                $playing = True
                play($current_station)
            Else
                $current_station = $current_station + 1
                If $current_station > $stations_count Then $current_station = 1
                play($current_station)
            EndIf
 
        Case _IsPressed($hotkey_previous)
            If $playing = False Then
                $playing = True
                play($current_station)
            Else
                $current_station = $current_station - 1
                If $current_station < 1 Then $current_station = $stations_count
                play($current_station)
            EndIf
 
        Case _IsPressed($hotkey_stop)
            $playing = False
            _SoundStop($sound)
 
        Case _IsPressed($hotkey_decrease)
            $volume = $volume - 5
            If $volume < 0 Then $volume = 0
            SoundSetWaveVolume($volume)
            ;sleep(50)
 
        Case _IsPressed($hotkey_increase)
            $volume = $volume + 5
            If $volume > 100 Then $volume = 100
            SoundSetWaveVolume($volume)
            ;sleep(50)
    EndSelect
if $playing = True and _SoundStatus($sound)=("stopped") Then play($current_station)
WEnd
 
Func play($station_number)
 
 
 
    $files = _FileListToArray($inst_path & $Stations[$station_number] & "\", "*")
    $random = Random(1, $files[0], 1)
    ConsoleWrite("Station: " & $station_number & "Song: " & $random & @CRLF)
 
    if $playing = True and _SoundStatus($sound)=("stopped") Then
    $new_track=True
    Else
    $new_track=false
    EndIf
    _SoundStop($sound)
    $sound = _SoundOpen($inst_path & $Stations[$station_number] & "\" & $files[$random])
 
if $new_track=True Then
    Else
    _SoundSeek($sound, "", "", Random(1, 59, 1))
    EndIf
    _SoundPlay($sound)
    ;if $ingame_title=$gui_checked then SplashTextOn("Splash",$Stations[$station_number]&" :"&$files[$random], 700, 30, -1, 10, 33)
    Sleep(300)
    $splash = 0
EndFunc  ;==>play
 
Func hotkeys($temp)
    If GUICtrlRead($temp) = ("a") Then
        $temp = ("41")
    ElseIf GUICtrlRead($temp) = ("b") Then
        $temp = ("42")
    ElseIf GUICtrlRead($temp) = ("c") Then
        $temp = ("43")
    ElseIf GUICtrlRead($temp) = ("d") Then
        $temp = ("44")
    ElseIf GUICtrlRead($temp) = ("e") Then
        $temp = ("45")
    ElseIf GUICtrlRead($temp) = ("f") Then
        $temp = ("46")
    ElseIf GUICtrlRead($temp) = ("g") Then
        $temp = ("47")
    ElseIf GUICtrlRead($temp) = ("h") Then
        $temp = ("48")
    ElseIf GUICtrlRead($temp) = ("i") Then
        $temp = ("49")
    ElseIf GUICtrlRead($temp) = ("j") Then
        $temp = ("4A")
    ElseIf GUICtrlRead($temp) = ("k") Then
        $temp = ("4B")
    ElseIf GUICtrlRead($temp) = ("l") Then
        $temp = ("4C")
    ElseIf GUICtrlRead($temp) = ("m") Then
        $temp = ("4D")
    ElseIf GUICtrlRead($temp) = ("n") Then
        $temp = ("4E")
    ElseIf GUICtrlRead($temp) = ("o") Then
        $temp = ("4F")
    ElseIf GUICtrlRead($temp) = ("p") Then
        $temp = ("50")
    ElseIf GUICtrlRead($temp) = ("q") Then
        $temp = ("51")
    ElseIf GUICtrlRead($temp) = ("r") Then
        $temp = ("52")
    ElseIf GUICtrlRead($temp) = ("s") Then
        $temp = ("53")
    ElseIf GUICtrlRead($temp) = ("t") Then
        $temp = ("54")
    ElseIf GUICtrlRead($temp) = ("u") Then
        $temp = ("55")
    ElseIf GUICtrlRead($temp) = ("v") Then
        $temp = ("56")
    ElseIf GUICtrlRead($temp) = ("w") Then
        $temp = ("57")
    ElseIf GUICtrlRead($temp) = ("x") Then
        $temp = ("58")
    ElseIf GUICtrlRead($temp) = ("y") Then
        $temp = ("59")
    ElseIf GUICtrlRead($temp) = ("z") Then
        $temp = ("5A")
    ElseIf GUICtrlRead($temp) = ("0") Then
        $temp = ("30")
    ElseIf GUICtrlRead($temp) = ("1") Then
        $temp = ("31")
    ElseIf GUICtrlRead($temp) = ("2") Then
        $temp = ("32")
    ElseIf GUICtrlRead($temp) = ("3") Then
        $temp = ("33")
    ElseIf GUICtrlRead($temp) = ("4") Then
        $temp = ("34")
    ElseIf GUICtrlRead($temp) = ("5") Then
        $temp = ("35")
    ElseIf GUICtrlRead($temp) = ("6") Then
        $temp = ("36")
    ElseIf GUICtrlRead($temp) = ("7") Then
        $temp = ("37")
    ElseIf GUICtrlRead($temp) = ("8") Then
        $temp = ("38")
    ElseIf GUICtrlRead($temp) = ("9") Then
        $temp = ("39")
    ElseIf GUICtrlRead($temp) = ("f1") Then
        $temp = ("70")
    ElseIf GUICtrlRead($temp) = ("f2") Then
        $temp = ("71")
    ElseIf GUICtrlRead($temp) = ("f3") Then
        $temp = ("72")
    ElseIf GUICtrlRead($temp) = ("f4") Then
        $temp = ("73")
    ElseIf GUICtrlRead($temp) = ("f5") Then
        $temp = ("74")
    ElseIf GUICtrlRead($temp) = ("f6") Then
        $temp = ("75")
    ElseIf GUICtrlRead($temp) = ("f7") Then
        $temp = ("76")
    ElseIf GUICtrlRead($temp) = ("f8") Then
        $temp = ("77")
    ElseIf GUICtrlRead($temp) = ("f9") Then
        $temp = ("78")
    ElseIf GUICtrlRead($temp) = ("f10") Then
        $temp = ("79")
    ElseIf GUICtrlRead($temp) = ("f11") Then
        $temp = ("7A")
    ElseIf GUICtrlRead($temp) = ("f12") Then
        $temp = ("7B")
    ElseIf GUICtrlRead($temp) = ("ESC") Then
        $temp = ("1B")
    Else
        $temp = "not_assigned"
    EndIf
 
    Return ($temp)
EndFunc  ;==>hotkeys
 
 
Func write($temp)
    If GUICtrlRead($temp) = $gui_checked Then
        $i = "True"
        FileWrite("Settings.txt", ($i) & @CRLF)
    ElseIf GUICtrlRead($temp) = $gui_unchecked Then
        $i = "False"
        FileWrite("Settings.txt", ($i) & @CRLF)
    Else
        FileWrite("Settings.txt", GUICtrlRead($temp) & @CRLF)
    EndIf
EndFunc  ;==>write
 
Func CheckboxCreation($displayed_text, $standard_value)
 
    GUICtrlCreateLabel($displayed_text, $xPos, $yPos, $label_width, $label_height)
    $temp = GUICtrlCreateCheckbox("", $xPos2, $yPos, 0, 20)
    If $standard = False Then
        If FileReadLine("Settings.txt", $zeilen_counter) = "True" Then GUICtrlSetState(-1, $gui_checked)
    Else
        If $standard_value = "True" Then GUICtrlSetState(-1, $gui_checked)
    EndIf
    $yPos = $yPos + $label_height + 1
    $zeilen_counter = $zeilen_counter + 1
    Return $temp
EndFunc  ;==>CheckboxCreation
 
Func InputCreation($displayed_text, $standard_value)
    GUICtrlCreateLabel($displayed_text, $xPos, $yPos, $label_width, $label_height)
    If $standard = False Then
        $temp = GUICtrlCreateInput(FileReadLine("Settings.txt", $zeilen_counter), $xPos2, $yPos, $label_width, $label_height)
    Else
        $temp = GUICtrlCreateInput($standard_value, $xPos2, $yPos, $label_width, $label_height)
    EndIf
 
    $yPos = $yPos + $label_height + 1
    $zeilen_counter = $zeilen_counter + 1
    Return $temp
EndFunc  ;==>InputCreation
 
 
Func MainExit()
    Exit
EndFunc  ;==>MainExit
 

Attachments

  • tag_instructions.png
    tag_instructions.png
    158.1 KB · Views: 1,824
  • Radio.zip
    373.4 KB · Views: 2,419
To change the hotkey you just edit:

from
;HotKeySet("{ESC}", "MainExit")
to
;HotKeySet("{F7}", "MainExit")

Is that right or am i doing something wrong?

EDIT:
disregard that, i read the "how to use part"
3. execute the program, assign the hotkeys or leave them blank if you don't need the feature.
 
it's right, but you have to remove the semicolon because with it it's a comment^^
nevertheless I should have added a exit hotkey in the gui, I will add it asap
 
thanks
After the update could you attach a compiled .exe
i'm a bit lazy to compile it myself
 
added hotkey to exit the programm, f1-f12 and esc should now work as well
I hope zip folder is ok, can't upload exe files
 
Great work! and when i say it i mean it.
I also use it with other games that dont have a radio (Just cause 2 anybody?)
 
added hotkey to exit the programm, f1-f12 and esc should now work as well
I hope zip folder is ok, can't upload exe files
sorry wrong use of the term "upload an exe"
if you consider the forum rules(linked in my signature) you should pack all mods/tools into a zip/rar/7-zip for the prevention of "file corruption"
 
I always get the following error as soon as I activate it in-game:
-----
Line 4984 (File "C:\[the filepath]"):
Error: Subscript used with non-Array variable.
-----
How do I fix this?
 
Back
Top