-
-
Save glutanimate/413c7e0a61b826d687a1 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
# MoodyRain by Glutanimate | |
# License: GNU GPLv3 | |
# Dependencies: yad, vlc | |
# | |
# All streams linked to in this script are the property of their respective owners. | |
# | |
# Using a different audio player: | |
# | |
# Replace the cvlc command-line with one of the following | |
# - mpv --loop=inf --vo null --volume="$Volume" --gapless-audio=yes "$i" #> /dev/null 2>&1 & | |
# - avplay -loop 0 -nodisp -autoexit "$i" > /dev/null 2>&1 & | |
# | |
# Using local files: | |
# | |
# place files with the same name as the streams in 'ambient_sounds' directory next to script | |
# (e.g. ./ambient_sounds/RainyMood.ogg) | |
# Variables | |
Executable="$(readlink -f "$0")" | |
ProgDir="${Executable%/*}" | |
SoundDir="$ProgDir/ambient_sounds" | |
StreamUrl=("http://174.36.223.28/audio1110/RainyMood.ogg" \ | |
"http://st2.asoftmurmur.com/beta/main-thunder.mp4" \ | |
"http://st3.asoftmurmur.com/beta/main-sbowl.mp4" \ | |
"http://st1.asoftmurmur.com/beta/main-birds.mp4" \ | |
"http://st3.asoftmurmur.com/beta/main-wind.mp4" \ | |
"http://st1.asoftmurmur.com/beta/main-whitenoise.mp4" \ | |
"http://st3.asoftmurmur.com/beta/main-waves.mp4" \ | |
"http://st1.asoftmurmur.com/beta/main-rain.mp4" \ | |
"http://st2.asoftmurmur.com/beta/main-people.mp4" \ | |
"http://st3.asoftmurmur.com/beta/main-fire.mp4" \ | |
"http://st2.asoftmurmur.com/beta/main-crickets.mp4" \ | |
"http://augustambience.com/night.mp3" \ | |
"http://www.soundrown.com/Audio/Final%20Normalized/mp33/FireFinal15.mp3" \ | |
"http://coffitivity.com/sounds/audio/mp3/morningMurmur_mp3.mp3" \ | |
"http://coffitivity.com/sounds/audio/mp3/lunchtimeLounge_mp3.mp3" \ | |
"http://coffitivity.com/sounds/audio/mp3/universityUndertones_mp3.mp3") | |
StreamName=("rainymood.com - Rainy Mood" \ | |
"A Soft Murmur - Thunder" \ | |
"A Soft Murmur - Singing Bowl" \ | |
"A Soft Murmur - Birds" \ | |
"A Soft Murmur - Wind (short)" \ | |
"A Soft Murmur - White Noise (short)" \ | |
"A Soft Murmur - Waves (short)" \ | |
"A Soft Murmur - Rain (short)" \ | |
"A Soft Murmur - People (short)" \ | |
"A Soft Murmur - Fire (short)" \ | |
"A Soft Murmur - Crickets (short)" \ | |
"August ambience - August Night" \ | |
"Soundrown - Fire" \ | |
"Coffitivity - Morning Murmur" \ | |
"Coffitivity - Lunchtime Lounge"\ | |
"Coffitivity - University Undertones") | |
Volume="100" | |
# Gui | |
YadTitle="MoodyRain" | |
TrayIcon="rhythmbox-panel" | |
GuiTxtDescr="Please select one or multiple ambient sounds. Internet connection required!" | |
GuiTxtPlay="Play selected streams" | |
GuiTxtCancel="Cancel and quit" | |
WmIcon="gnome-audio" | |
ThumbIcon="gnome-audio" | |
# Functions | |
gui_streamsel () { | |
YadChoices="$(\ | |
for i in "${!StreamUrl[@]}"; do | |
echo "FALSE" | |
echo "${StreamName[$i]}" | |
echo "${StreamUrl[$i]}" | |
done | \ | |
yad --list --checklist \ | |
--title="$YadTitle" \ | |
--class="$WmClass" \ | |
--text="$GuiTxtDescr" \ | |
--window-icon="$WmIcon" \ | |
--image="$ThumbIcon" \ | |
--print-all --multiple \ | |
--width=800 --height=400 --center \ | |
--button="_Play!gtk-media-play-ltr!$GuiTxtPlay":2 \ | |
--button="_Cancel!gtk-close!$GuiTxtCancel":1 \ | |
--column="Choose" \ | |
--column="Stream":TEXT --column="Stream URL":TEXT \ | |
)" | |
YadChoicesRet="$?" | |
Playlist=($(echo "$YadChoices" | grep "TRUE" | cut -d '|' -f 3)) | |
Sounds=($(echo "$YadChoices" | grep "TRUE" | cut -d '|' -f 2 | awk -F '\n' '{print $1", "}')) | |
if [[ "$YadChoicesRet" != "2" || -z "$Playlist" ]]; then | |
echo "Aborted." | |
exit 1 | |
fi | |
} | |
gui_systray () { | |
yad --notification \ | |
--text="MoodyRain" \ | |
--image="$TrayIcon" \ | |
--command="notify-send -i $ThumbIcon 'MoodyRain' 'Ambient sounds: ${Sounds[*]}'" \ | |
--menu="Stream selection!bash -c gui_systray_onclick!$ThumbIcon|Exit!kill -s TERM $TopPid!exit"& | |
YadPid="$!" | |
} | |
gui_systray_onclick(){ | |
kill -s TERM "$TopPid" | |
"$TopScript" > /dev/null 2>&1 & | |
} | |
player(){ | |
for i in "${Playlist[@]}"; do | |
# prefer local data | |
if [[ -f "$SoundDir/${i##*/}" ]]; then | |
PlaylistItem="$SoundDir/${i##*/}" | |
echo "Playing local file $PlaylistItem" | |
else | |
PlaylistItem="$i" | |
echo "Playing remote stream $PlaylistItem" | |
fi | |
cvlc --repeat --volume=$((256*Volume/100)) --play-and-exit "$PlaylistItem" > /dev/null 2>&1 & | |
PlayerPids+=("$!") | |
done | |
wait "${PlayerPids[0]}" | |
} | |
cleanup(){ | |
for i in "${PlayerPids[@]}"; do | |
kill -s TERM "$i" | |
done | |
kill -s TERM "$YadPid" | |
kill -s TERM "$TopPid" | |
} | |
# Preamble | |
export -f gui_systray_onclick | |
export TopScript="$0" | |
export TopPid=$$ | |
PlayerPids=() | |
trap "cleanup; exit" EXIT | |
# Main | |
gui_streamsel | |
gui_systray | |
player |
Would you be fine with me using your sounds for moodyrain?
Off course! Just put links to the original files somewhere.
Awesome, thanks a lot! I just released an overhauled version of MoodyRain with your samples included. I would be glad if you and @orschiro gave it a try.
One small thing about the sound files:
I noticed that they all have even-numbered durations (in seconds). I think it could be beneficial to use tracks with more differing durations.
See, if we only use even-numbered tracks with similar lengths we have far more overlapping seams...
track 1 |-----|-----|-----|-----| period: 120 secs
track 2 |--|--|--|--|--|--|--|--| period: 60 secs
track 3 |-----------|-----------| period: 240 secs
...than if we use sound files with more variance in their periods:
track 1 |----|----|----|----|----| period: 89 secs
track 2 |---|---|---|---|---|---|- period: 72 secs
track 3 |------|------|------|---- period: 131 secs
This could reduce repetitiveness and create a more natural-sounding soundscape.
Just a thought, though. I haven't had the chance to play around with audacity, yet. I might very well be talking nonsense here.
Awesome, thanks a lot! I just released an overhauled version of MoodyRain with your samples included. I would be glad if you and @orschiro gave it a try.
Just one problem: file -Lib "$File"
(on line 36) returns audio/ogg
(instead of application/ogg
) on my system (archlinux). You should probably check if it's equal to */ogg *
, or find a better way. Appart from that it works fine.
I noticed that they all have even-numbered durations (in seconds). I think it could be beneficial to use tracks with more differing durations.
At first I thought too that it would be important to reduce repetitiveness, but for A soft murmur for examples, all the audio files are two minutes long if I remember correctly, and you can listen to them for hours without realising that it is always the same two-minutes segment.
I've been listening to the tracks I edited a lot, and at least once for a whole hour without pause, and I don't hear any repetition, so it should be good.
Although you are probably right, I should be careful when creating tracks that do not always sound the same (such as the Thunderstorm), if all of them have the same length, some pattern may appear.
Just one problem: file -Lib "$File" (on line 36) returns audio/ogg (instead of application/ogg) on my system (archlinux).
Huh, I must say I am quite surprised that file
behaves differently on Arch. Thanks for the pointer! It should be fixed now
I've been listening to the tracks I edited a lot, and at least once for a whole hour without pause, and I don't hear any repetition, so it should be good.
Although you are probably right, I should be careful when creating tracks that do not always sound the same (such as the Thunderstorm), if all of them have the same length, some pattern may appear.
Yeah, you did a fantastic job with the edits. So far I've only been able to discern a repetitive pattern in the thunderstorm sample.
Yeah, you did a fantastic job with the edits. So far I've only been able to discern a repetitive pattern in the thunderstorm sample.
I'm not really happy with that one, I'll try to find a long and nice rolling thunder sound when I have the time.
@Muges:
Very interesting project! I love how you can adjust the volume for each track. The tracks loop perfectly, too, so fantastic job on that!
Would you be fine with me using your sounds for moodyrain?
I will definitely check out the audacity tutorials you linked to. I don't have much time on my hands right now, but when I eventually do get down to compiling ambient loops of my own I will make sure to let you know.
Glad I could help with the samples!