ClareXoBearrx3R9 Posted June 28, 2011 Share Posted June 28, 2011 Hello everyone, In the GTA IV police vehicles, there is a scanner that plays a random set of sounds. Basically, the dispatcher has a number of sound files including "Crimes", "Conjunctives", "Areas", "Streets", "Vehicles", etc. There is a code somewhere in the game that picks a random sound from each category (in a specific order) and plays them as the police scanner. I was wondering if I could do this myself...I have all the sound files in .WAV format and would like to write something like this for my clan, to have as a custom scanner, so that we have some pretend situations to respond to. I have some knowledge in Flash Actionscript 3.0, and C++, as well as some knowledge in html. Is there anything that anyone could think of something to writing to do such a thing? Any help is greatly appreciated!!! Thanks Link to comment Share on other sites More sharing options...
mkey82 Posted June 28, 2011 Share Posted June 28, 2011 This really does not belong in this section, there is modding subforum here, you know. Do you want to do this ingame or as a separate program? Link to comment Share on other sites More sharing options...
ClareXoBearrx3R9 Posted June 28, 2011 Author Share Posted June 28, 2011 Oh, I'm sorry I wasn't exactly sure where it was supposed to go. Anyway, I wanted to do it as a separate program. Link to comment Share on other sites More sharing options...
mkey82 Posted June 29, 2011 Share Posted June 29, 2011 Well, you'll have to organise your files in some directory structure, then it's probably best to have various playlists, organized to your liking, and finally have a program load the files from those playlists randomly. You can probably use some external player so that coding needs would be minimal. Link to comment Share on other sites More sharing options...
ClareXoBearrx3R9 Posted June 30, 2011 Author Share Posted June 30, 2011 Thanks for the info So I might have to do it through a media player or something like that. Are you aware of there being any codes for something like this, say on a website? (eg.: A code that would allow me to run something like this on a website, treating it as background music). I guess the main thing is I've got the files organized in a file & folder structure, I'm just not sure how to get them to play randomly. Link to comment Share on other sites More sharing options...
mkey82 Posted June 30, 2011 Share Posted June 30, 2011 The algorithm would be the following: 1. organise the files (try using standard mp3) in a folder structure 2. create playlists which match your needs 3. create a program that will follow some logic you may need. The program will read the playlists contents and then randomly choose an entry from the playlist, using a certain order which matches your needs. There are many functions which can be used for this to happen, like c++ rand() function which outputs a random number from 0 to 1. So, if you need a random index from 0 to 101 you would use floor(rand()*102). floor() is another c++ function. Files in the playlists can be added with full or relative file path, relative is better as it will allow you to pass on the program to somone else. If you place all the files (including the program) in the game directory, that's probably for the best. 4. All of this can be greatly simplifed if you use a special file naming convention. Lets say you have one mysounds folder and in it 11 folders, named 0-10. Each folder may contain files named 0.mp3 to x.mp3. In this case, your program needs to store x for every folder and then you just randomly generate numbers to build paths. Ex. // this one holds your game logic, folder index from 0-10, according to above exampleint internal_logic;// this holds the number of mp3 files per folder, 11 folders, 11 entriesarray index[11]= { 50, 87, 55, 10, 38, 25, 45, 86, 100, 15, 20 };// finally the pathstring mp3path= "mysounds\" + inernal_logic + "\" + floor(rand() * index[internal_logic]) + ".mp3"; 5. finally, you may use a commandline mp3 player, like this one to actually play the files. You would use something like this start /w cmdmp3win.exe mysounds\0\0.mp3here you would actually use the mp3path variable from above which can be fed to ShellExecute() function. It's also rahter easy writing some mp3 reading function, you may look it up on the web. OK, I'll now actually stop before I write, compile and build the program for ya Link to comment Share on other sites More sharing options...
ClareXoBearrx3R9 Posted July 1, 2011 Author Share Posted July 1, 2011 Wow. That was an awesome explanation! I'm wondering if I could save some work from building a playlist and perhaps have the program randomly select a sound file in order of specific directories, instead. I'll definitely rename the files as you suggested with a special convention. Perhaps I'll write this in c++. I'll try that first. Thanks again for your detailed explanations! Very helpful! I'll post here my progress with the program. Link to comment Share on other sites More sharing options...
mkey82 Posted July 1, 2011 Share Posted July 1, 2011 You don't need the playlist, you can use the above provided file naming convention or just use a function like FindFile(). Link to comment Share on other sites More sharing options...
ClareXoBearrx3R9 Posted July 1, 2011 Author Share Posted July 1, 2011 Oh. Hmm. I might try both, to see which is easier. Thanks again Link to comment Share on other sites More sharing options...
mkey82 Posted July 1, 2011 Share Posted July 1, 2011 The first one with files organized by logic in folders is definitely easier. Link to comment Share on other sites More sharing options...
ClareXoBearrx3R9 Posted July 1, 2011 Author Share Posted July 1, 2011 Yeah, good point. Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now