WIP Beta released Radio/Music Player v0.8.2

Discussion in 'Utilities and programming' started by TheStatPow, Nov 7, 2015.

?

Do you like this mod?

  1. Yes, a lot!

    180 vote(s)
    95.2%
  2. No, a lot!

    9 vote(s)
    4.8%
  1. TheStatPow

    TheStatPow
    Expand Collapse

    Joined:
    Aug 8, 2013
    Messages:
    145
    Its there!

    But with some limitation (sorry some bugs just don't want to go away, working hard on fixing them :c)

    BEAMNG DEVS, (I love you a lot) ,READ THIS PLEASE:

    For the radio part of this mod i load multiple sound and the same time, they play at very low volume in the background when the player is not listening to them, only the one selected is playing.

    Thing is, when the engine starts working hard, like crashing the car hard, or on big maps like Jungle rock (Fukken awesome maps btw!) the sounds, fast foward, making the radio either restart at the beginning if i use AudioMusicLoop3D, or just reaches the end of the sound file if i use AudioMusic3D

    (its weird, but i think its the pitch doppler effect's fault)

    How would I go about making my sound not affected by the pitch/doppler effect (even though I love it, it sound like tape warping :D )

    Also, How do i check if player switchs camera? Im pretty sure it as to be like "if input.keys.F then"
    but "if input.keys.Camera_switch then" ect does nothing. its Nil

    Also again, how do i make it know if the song as ended?

    MOD USERS, (I love you even more) ,READ THIS PLEASE:

    [WARNING]
    This is in beta, there are lots of bugs im aware of, heres the list:

    -Use i to respawn your car and not ctrl-r (ctrl_r reload the scripts)
    you need to reinput the command to start the radio if you spawn a new car

    Also, close the radio before spawning a new car, or else the sound stay where the previous car was.
    (gonna fix that soon)

    -Pitch/doppler effect can be annoying

    -The mod can't make the difference yet between which camera you are (external/interior)
    so DON'T use external camera yet (doesn't feel as real i already have some code ready so it sounds like it comes from inside the car, and not the hood)

    so use the interior camera!

    -The music comes from the hood in the interior camera (if it comes from the dashboard or the seats or whatever, it doesn't sound 3D) So if the hood detach and go away in a crash the music will stay with the hood

    -DO NOT USE THE RADIO STATIONS FOR NOW, only use the song playlist. radio unloads or fast foward randomly when not selected, as stated in the notice above.

    -If you crash too hard the radio stops and break (Thats not a bug, its a feature)

    [Installing the mod]:

    1: Goto C:\Steam\SteamApps\common\BeamNG.drive\lua\vehicle

    2: Make a back up of your sounds.lua file (Important if things go wrong)

    3: Replace it by the sounds.lua file i just provided to you

    4: Insert cheesy joke here about how theres no number 4

    [Adding Music/Radio]:

    The default directory for the music and radio is C:\Steam\SteamApps\common\BeamNG.drive\art\music

    You can change it by going in the code.

    !IMPORTANT! The mod takes .mp3/.wav/.ogg but they need to be MONO and not stereo (easy to do in audacity)

    Put your music files in there, and put your radio stations (Just albums or one of those radio you can take on youtube *cough* Gta *cough*) in the radio folder.

    Should look like this:



    [Using the Mod]

    For now its command line and keys, but Ill work toward making an UI App when its fixed.

    First, you need to bind the keys to switch songs or stations, theres 2 key, one to switch to the right, and one to the left.

    To do that go in the control settings - Advanced - Vehicle

    Function F is to switch songs to the left in the playlist (or radio station)

    And Function E is to the right!

    (Function Y is to close the radio, to reopen it just switch songs/station)

    Note: You will have to switch song when they end, the script doesn't know yet when a song end, idk how to do that yet :c

    Choose the keys you want to use! (I personally use 1 2 3 from the numbers on top of the keyboard)




    After this, open the console. and select "Lua - Vehicle"




    There are 2 commands:

    One to load the radio stations: 'sounds.radioLoadRadio()'

    One to load the Music playlist: 'sounds.radioLoadSound()'

    The volume of the radio is tied to the music slider in the audio settings!

    Enjoy the mod!!



    [To Come]:

    -Automaticly convert stereo to mono, or even better. surround sound so the left portion of the audio is gone if the left door is gone ect.. ?

    -Currently limited to 5 radio station, will recode it so its dynamicly and you can have as many as you want

    -Multiple music Playlists

    -Bug fixes (One can dream ;( )

    -UI APP (When they fix it and update the tutorial on the wicked wiki)

    -External camera effects (when the door is closed, you barely hear the music, when its open you hear it louder) (The whole code for that is already done but idk how codewise i can make the difference between which camera the player is on)
     

    Attached Files:

    #1 TheStatPow, Nov 7, 2015
    Last edited: Nov 8, 2015
    • Like Like x 7
  2. TheStatPow

    TheStatPow
    Expand Collapse

    Joined:
    Aug 8, 2013
    Messages:
    145
    To those who just download the first file, i just updated it, Function E (to swap right) was not working, its working now, redownload it!
     
  3. torsion

    torsion
    Expand Collapse

    Joined:
    May 31, 2015
    Messages:
    1,600
    I just grabbed it, but I won't be able to take a look right away.
     
  4. ktheminecraftfan

    ktheminecraftfan
    Expand Collapse

    Joined:
    Mar 14, 2014
    Messages:
    2,103
    it would be cool feature to have in the upcomming campaign mode.
     
    • Like Like x 1
  5. Narwhal

    Narwhal
    Expand Collapse

    Joined:
    Aug 4, 2013
    Messages:
    1,698
    YAY. its out. now i wish my ninite and my nvidia graphic drivers would hurry up. Looking foward to using this soon.
     
    • Like Like x 1
  6. torsion

    torsion
    Expand Collapse

    Joined:
    May 31, 2015
    Messages:
    1,600
    I haven't run this yet, but I think it would be worthwhile for you to diff your sounds.lua against the stock one. Looks like a couple of small things could use some cleanup.
    Code:
    local heelsSounds = {}
    (remove - this is unused and a typo I think?)
    Code:
        playWheelSound(wi, "SkidTestSound", skidVol, 1)
        playWheelSound(wi, "RollingTestSound", rollVol, 1)
    (not sure why these were changed, I assume you were testing)

    Also, in reference to the problem where the radio restarts after a big crash - does this happen even with your "radio broke" stuff commented out?
     
  7. TheStatPow

    TheStatPow
    Expand Collapse

    Joined:
    Aug 8, 2013
    Messages:
    145
    heelssound was used yes as a test but, im not much about cleaning my code when its still in beta.

    the other playwheelsound, I was testing too, was learning from reverse engineering.


    The radio broke stuff uses the G meter, i removed it, the problem was still there, that code is not commented out, the code commented out was part of the code for the external camera stuff "so it plays like its inside the car" it attach the sound to a door node instead of the hood.

    and bring the volume down until the door is open, still not where the problem is coming from, as you can see that code is commented out
     
  8. TheStatPow

    TheStatPow
    Expand Collapse

    Joined:
    Aug 8, 2013
    Messages:
    145
    Also, I wanted to make it a separate script, but that means i had to edit a line in the main.lua and i wanted the users to have close to nothing to do to install the mod.

    Gonna go take a shower and clean the code and put some comments in it when i get back.
     
  9. TheStatPow

    TheStatPow
    Expand Collapse

    Joined:
    Aug 8, 2013
    Messages:
    145
    Second patch is out for the mod!

    Cleaned up the code a little tiny bit :p

    [Bug fixed]:

    -Turning radio stations back on after closing the radio using Function Y wouldn't turn them back on.
    -Swiping left on the first radio station wouldn't foward it to the last radio station.

    [Feature added]:

    -Filenames (Song titles/Radio station titles) now show up on the top as a Gui message.

     
  10. Dummiesman

    Dummiesman
    Expand Collapse

    Joined:
    Sep 17, 2013
    Messages:
    4,685
    You should clean your code even in Beta. Considering you'll be building upon this code to make it final. ;)
     
    • Like Like x 1
  11. Scepheo

    Scepheo
    Expand Collapse

    Joined:
    Feb 10, 2015
    Messages:
    601
    It'll also make it a lot easier to port your code over to a UI app. At least, I'm assuming this will all be done in an app eventually?
     
    • Like Like x 1
  12. TheStatPow

    TheStatPow
    Expand Collapse

    Joined:
    Aug 8, 2013
    Messages:
    145
    Thats true, ill do it now :D
     
  13. HR28QT

    HR28QT
    Expand Collapse

    Joined:
    Aug 4, 2013
    Messages:
    409
    If this gets implemented into the game, it would be amazing if the center console had some dials that spun when you changed the song, or it displays what song is playing on the center console screen.
    If it isn't implemented, its a great idea for this mod if it is possible in any way.
    radio.png
     
  14. TheStatPow

    TheStatPow
    Expand Collapse

    Joined:
    Aug 8, 2013
    Messages:
    145
    Defintely gonna try, Im at least gonna try to do a 3D UI usiing the same function that draws the debug nodes on the car.
     
    • Like Like x 1
  15. HR28QT

    HR28QT
    Expand Collapse

    Joined:
    Aug 4, 2013
    Messages:
    409
    How about for some of the newer in-game cars, with tocuhscreens that in real life would have some fancy UI with the vehicle company's logo on it, or some of the really old cars, with simply an AM and FM dial.
     

    Attached Files:

    • center.jpg
    • stang.jpg
  16. torsion

    torsion
    Expand Collapse

    Joined:
    May 31, 2015
    Messages:
    1,600
    My feeling is still that this might best be cleaned up into another module. You've already got the user typing console commands, so why not have it be radio.LoadSound() rather than sounds.radioLoadSound()

    If you'd like you can compare your structure against Incognito's structure over here: http://www.beamng.com/threads/waypoints-paths-for-cars-v1-0-7.2947/

    There's also a UI app in that mod, but I don't know what the status is RE the changes in 0.4.3.0.

    Be sure to look at Incognito's "help.zip", which explains that main.lua must be modified to load this module. You could either prepack a modified main.lua (not very futureproof but easier to maintain) or just adapt Incognito's installation instructions to cover your mod as well. From a code perspective this seems much cleaner and easier to maintain. (Plus, hopefully auto-loading modules in the mods/ folder could come in a future release and you'd already be ready for it.)
     
  17. torsion

    torsion
    Expand Collapse

    Joined:
    May 31, 2015
    Messages:
    1,600
    On another note, as per your question about checking to see when a sound is done playing... doesn't look like T3D does that, but if you load up your sound files inside SFXProfiles I suppose that you can use "SFXProfile::getSoundDuration" to know how long to wait before playing the next one.
     
  18. TheStatPow

    TheStatPow
    Expand Collapse

    Joined:
    Aug 8, 2013
    Messages:
    145
    Ill get to it if im not too lazy, thanks for the info.
     
  19. Scepheo

    Scepheo
    Expand Collapse

    Joined:
    Feb 10, 2015
    Messages:
    601
    Or, if you have people typing console command anyway, just have them start with extensions.loadModule("radio"), that way no alterations of game files are necessary. Just pack your mod like radio.zip/lua/radio.lua (or something similar) and it should work.
     
  20. TheStatPow

    TheStatPow
    Expand Collapse

    Joined:
    Aug 8, 2013
    Messages:
    145
    Oh thanks.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice