Before...
There was nothing...
Mute...
But then...
He said...
And it was good...
After 5 years!
no wait...
Or 6 years!
nope...
Or however long TPT has existed!
People wanted sound!
Well here it is!
After one year of work!
Backround Music!
AND SOUND EFFECTS WOOOO
How to install backround music:
1. Have linux. I'm sorry Windows users, I really am, but I simply cannot tolerate working with Microsoft's unfinished bloatware-filled thing they call an OS. I do encourage the community to transcribe it, and I will add it to the instructions once it is made, but for now, you must wait...
2. Go to /home/$USER/Music
3. Create a folder called "PowderToy" (no quotes)
4. Put a .wav file in there (or multiple really) and name it "canon.wav"* (without quotes)
*I recommend this one: https://www.online-convert.com/downloadFile/104cc510-89d5-436e-a9b0-7e4b455a32a1/f87eff78-d811-4b46-a71f-9ab4b32fcdf5
5. Go to your Powder Toy directory
6. Create a folder called "scripts" (without quotes)
7. Create a .lua file named "sound" (without quotes)
8. Paste this into it:
function music()
os.execute('"./sound_play.sh" /home/$USER/Music/PowderToy/canon.wav')
end
music()
function stopmusic()
os.execute("killall play")
end
9. Go back to your powder toy directory
10. Create an .sh file named "sound_play" (without quotes)
11. Paste this into it:
play -q $1 &
12. Save all
13. Open powder toy
14. Open console (~)*
*Please note that if you have the script manager, just load it from there!
15. Type "dofile("scripts/sound.lua")" (without the top layer of quotes)
16. Enjoy whatever music you put
Commands: (without quotes)
1. "music()" - Plays "canon.mp3"
2. "stopmusic()" - Stops all music. You MUST use this before closing TPT!!!
BETA! SOUND EFFECTS!
WARNING: SOUND EFFECTS ARE VERY LAGGY AND I HIGHLY SUGGEST YOU USE THE SCRIPT MANAGER SO YOU CAN TURN THEM OFF!!! I HAVE TAKEN MANY PRECAUTIONS TO PREVENT HEARING DAMAGE, HOWEVER, PLEASE USE THIS CAREFULLY AS TO NOT HARM YOURSELF IN ANY WAY!!!
How to install sound effects:
1. Follow steps 1-4 for backround music
2. Download these:
https://drive.google.com/drive/folders/0B3CHCDEEHeU-bnVUbHljRTJ0V1E?usp=sharing
3. Place them in the music folder
4. Follow steps 5-7 for backround music
5. Paste this into sound.lua:
function music()
os.execute('"./sound_play.sh" /home/$USER/Music/PowderToy/canon.wav')
end
function bang_noise()
if tpt.set_pause() == 0 and sim.elementCount(tpt.element("embr")) > 0 or tpt.set_pause() == 0 and sim.elementCount(tpt.element("ligh")) > 0 then
tpt.set_property("type", "none", "embr")
os.execute('"./sound_play.sh" /home/$USER/Music/PowderToy/boom.wav')
end
end
function fire_noise()
if tpt.set_pause() == 0 and sim.elementCount(tpt.element("fire")) > 0 or tpt.set_pause() == 0 and sim.elementCount(tpt.element("plsm")) > 0 then
os.execute('"./sound_play.sh" /home/$USER/Music/PowderToy/fire.wav')
os.execute('"./sound_play.sh" /home/$USER/Music/PowderToy/wind.wav')
end
end
function radiation_noise()
if tpt.set_pause() == 0 and sim.elementCount(tpt.element("prot")) > 0 or tpt.set_pause() == 0 and sim.elementCount(tpt.element("neut")) > 0 or tpt.set_pause() == 0 and sim.elementCount(tpt.element("phot")) > 0 then
os.execute('"./sound_play.sh" /home/$USER/Music/PowderToy/radiation.wav')
end
end
function radioactive_waste_noise()
if tpt.set_pause() == 0 and sim.elementCount(tpt.element("uran")) > 0 or tpt.set_pause() == 0 and sim.elementCount(tpt.element("plut")) > 0 or tpt.set_pause() == 0 and sim.elementCount(tpt.element("polo")) > 0 or tpt.set_pause() == 0 and sim.elementCount(tpt.element("deut")) > 0 then
os.execute('"./sound_play.sh" /home/$USER/Music/PowderToy/radioactive_waste.wav')
end
end
function acid_noise()
if tpt.set_pause() == 0 and sim.elementCount(tpt.element("acid")) > 0 or tpt.set_pause() == 0 and sim.elementCount(tpt.element("virs")) > 0 then
os.execute('"./sound_play.sh" /home/$USER/Music/PowderToy/acid.wav')
end
end
function gas_noise()
if tpt.set_pause() == 0 and sim.elementCount(tpt.element("wtrv")) > 0 or tpt.set_pause() == 0 and sim.elementCount(tpt.element("fog")) > 0 or tpt.set_pause() == 0 and sim.elementCount(tpt.element("nble")) > 0 or tpt.set_pause() == 0 and sim.elementCount(tpt.element("gas")) > 0 or tpt.set_pause() == 0 and sim.elementCount(tpt.element("oxyg")) > 0 or tpt.set_pause() == 0 and sim.elementCount(tpt.element("caus")) > 0 or tpt.set_pause() == 0 and sim.elementCount(tpt.element("hygn")) > 0 or tpt.set_pause() == 0 and sim.elementCount(tpt.element("boyl")) > 0 or tpt.set_pause() == 0 and sim.elementCount(tpt.element("co2")) > 0 or tpt.set_pause() == 0 and sim.elementCount(tpt.element("smke")) > 0 then
os.execute('"./sound_play.sh" /home/$USER/Music/PowderToy/gas.wav')
end
end
function gel_noise()
if tpt.set_pause() == 0 and sim.elementCount(tpt.element("gel")) > 0 or tpt.set_pause() == 0 and sim.elementCount(tpt.element("bizr")) > 0 or tpt.set_pause() == 0 and sim.elementCount(tpt.element("soap")) > 0 then
os.execute('"./sound_play.sh" /home/$USER/Music/PowderToy/gel.wav')
end
end
function water_noise()
if tpt.set_pause() == 0 and sim.elementCount(tpt.element("watr")) > 0 or tpt.set_pause() == 0 and sim.elementCount(tpt.element("dstw")) > 0 or tpt.set_pause() == 0 and sim.elementCount(tpt.element("sltw")) > 0 or tpt.set_pause() == 0 and sim.elementCount(tpt.element("bubw")) > 0 or tpt.set_pause() == 0 and sim.elementCount(tpt.element("soap")) > 0 or tpt.set_pause() == 0 and sim.elementCount(tpt.element("oil")) > 0 or tpt.set_pause() == 0 and sim.elementCount(tpt.element("desl")) > 0 or tpt.set_pause() == 0 and sim.elementCount(tpt.element("merc")) > 0 then
os.execute('"./sound_play.sh" /home/$USER/Music/PowderToy/water.wav')
end
end
function electricity_noise()
if tpt.set_pause() == 0 and sim.elementCount(tpt.element("sprk")) > 0 or tpt.set_pause() == 0 and sim.elementCount(tpt.element("elec")) > 0 then
os.execute('"./sound_play.sh" /home/$USER/Music/PowderToy/electricity.wav')
end
end
tpt.register_step(fire_noise)
tpt.register_step(bang_noise)
tpt.register_step(radiation_noise)
tpt.register_step(radioactive_waste_noise)
tpt.register_step(water_noise)
tpt.register_step(gas_noise)
tpt.register_step(electricity_noise)
tpt.register_step(acid_noise)
tpt.register_step(gel_noises)
function stopmusic()
os.execute("killall play")
end
6. Follow steps 9-13
7. Activate it in the Script manager
Current sound effects:
- Water, MERC, DESL, OIL
- PLUT, URAN, POLO, DEUT
- FIRE, PLSM
- TNT, BOMB, FIRW, LIGH, THDR
- PROT, NEUT, PHOT
- ACID, VIRS
- GEL, SOAP, BIZR
- Gases
- Electricity, ELEC
- Possibly others that were unintended
USE SOUND EFFECTS LIGHTLY!!!
DO NOT USE IT WITH ELECTRONICS, IT IS ALREADY VERY LAGGY!!!
BE CAREFUL!
Update Log:
V1.2:
Fixed volume levels for sound effects - No need to change volume when switching from fire to water
Added sound for: LIGH and THDR
V1.3:
Added sound for: ACID, All Gases, Electricity (I still do not recommend saves with it but ok whatever...), & VIRS
Optimized everything (somehow)
Mined for fish
V1.4:
Fixed music() volume
Added sound for: MERC, DESL, OIL, SOAP, GEL, BIZR, ELEC, PHOT, DEUT
V1.5:
Made sound stop on pause
V1.6:
Fixed V1.5
Todo:
Fix ignition cord
Add more sound
^^^^ Do that again
Fix music() volume
Make sound stop while paused
(Eventually) Make for windows
Mine for fish
I will use this as a questions megathread, so please keep in touch!
Draco712:
P.S. Microsoft isn't the one who puts bloatware onto your system. It's your computer's vendor (for example Lenovo) who places these (potentially harmful) bloatware. *looks at Lenovo again*
1. They shouldn't let them
2. Windows 10, Candy Crush
3. I'd love it if you could upload for Windows
UPDATE:
Currently working on loop and sound ending detection.
What does this mean?
It means sound effects soon!
As it turns out, there is no way to stop sounds before closing, sorry...
UPDATE 2:
I got sound effects working!
You guys ready?
I AM!!!
QUESTION:
Is there a way to check for the highest pressure on screen?
Here it is, though it adds an element that makes a tone: NOTE. Sample save inside .zip file.
README.txt:
-------------------------
== The Sounder for TPT ==
-------------------------
This script introduces a way to play audio in TPT, using an external
program called sounder.exe by Eli Fulkerson:
[https://www.elifulkerson.com/projects/commandline-wav-player.php]
Also adds a NOTE element, which plays a... note! (See usage below)
sounder.exe is already included in this package without modifications.
If you want, download the .exe from the site above and replace the one
in this package for your peace of mind.
NOTE: Just *very* recently, the author said of reports that sounder is
treated as a virus by Windows Defender (well, I don't trust Win Def),
and I ran a scan at VirusTotal. Only 2 (eGambit and SentinelOne)
treated it as malicious. Not a risk (for me :P).
USAGE:
::Extract the zip file into your Powder directory. Your powder directory
should have the folder 'tone' in it. And also make sure of this:
[[just read the README, structure messed up here.]]
::Add this line into your autorun.lua (preferably at top):
require('tone/init')
::..and save the file.
::Start TPT, and it should log "sounder initialized.".
NOTE element.
::To use the NOTE element, navigate to the Electronics section. It's colored
blue. Place the element and spark it on any side. Control temp for the
duration in frames, and tmp 1-10 for the tones.
NOTE2: While sounding, this produces a command line box. Might be quite
annoying if there are *many* NOTEs activated.
TODO
--------
See forum post.
http://tpt.io/.301283
TODO:
-Add more tones/pitches.
-ctype sets the type of tone.
-find another way to play audio to get rid of those ridiculous command prompt pop-ups.
-update: (look into proteaAudio for lua)
-Still a prototype. Tell me if there are any problems (besides the pop-ups).
-say hello to windows 10 and lenovo :P
Zip file (my site is used here. :P)
https://adr712.cu.ma/TPT/TPT_Sound_v0-0-1.zip
I think you need to iterate over all the pressure cells in the sim through the sim.pressure function. Quite intensive, but yeah, that's what I could think of for now.
I love what you've done!
I hope you will do the sound effects!
I am working on a version that might work but I'd love to see what you make!
@Draco712 (View Post) said:
I think you need to iterate over all the pressure cells in the sim through the sim.pressure function. Quite intensive, but yeah, that's what I could think of for now.
Ah, it's already too laggy for my low-end GTX-950 & i3 proccesser at about 45-ish fps. I may release an update for high-end CPU's as my 1050-Ti & AMD RYZAN runs at 65-ish fps. We will see...
UPDATE:
Working on a mute button.
Yeah.
It's better than it sounds. (Pun not intended)
sudo apt-get install soxon ubuntu/debian systems. Alternatively, change the command to "aplay", which I did have installed by default.
Sorry that this took so long.
I did not know you needed sox. I'm changing to aplay.
I did not know you could zip that. Thanks! :)
Ah yes, the whole static thing. I'm working on it.
Apparently my headphones limit the amount of sound going through, so it sounded much better to me.
The problem is that both play and aplay have a mode where you can play it the backround, as to not freeze TPT. The problem is, I can no longer detect when the sound is finished playing. I tried using framecounting, but when TPT lags, the sound doesn't. So that's out the window. I've tried using a special wait() function, but that kept freezing TPT.
Please give me ideas. I'm trying to make a system to calculate the amount of frames based on the current FPS, but i'm so confused with it.
Also I have the problem of stopping the sound. You know, backound playing is annoying.
I hope someone makes this work for windows.
I hate windows, and I dont want to deal with its sound system.
If you would like i'll add a note element.