Made some more changes to volume command

This commit is contained in:
Matthieu Grieger 2014-10-24 14:48:41 -07:00
parent 520b86aa33
commit 4d611d7576
4 changed files with 20 additions and 13 deletions

View file

@ -1,6 +1,10 @@
MumbleDJ Changelog MumbleDJ Changelog
================== ==================
### October 24, 2014
* Switched volume change method. The volume is now changed directly through `piepan` instead of `ffmpeg`.
* Fixed another bug with volume changing.
### October 23, 2014 ### October 23, 2014
* Fixed a bug that would not allow audio encoding to complete successfully while on Debian. * Fixed a bug that would not allow audio encoding to complete successfully while on Debian.
* Fixed a stupid typo that broke the `!volume` command. * Fixed a stupid typo that broke the `!volume` command.

View file

@ -24,17 +24,17 @@ config.COMMAND_PREFIX = "!"
-- DEFAULT VALUE: true -- DEFAULT VALUE: true
config.OUTPUT = true config.OUTPUT = true
-- Default volume (256 being normal volume) -- Default volume (1 being normal volume)
-- DEFAULT VALUE: 32 -- DEFAULT VALUE: 0.5
config.VOLUME = 32 config.VOLUME = 0.5
-- Lowest volume allowed -- Lowest volume allowed
-- DEFAULT VALUE: 16 -- DEFAULT VALUE: 0.01
config.LOWEST_VOLUME = 16 config.LOWEST_VOLUME = 0.01
-- Highest volume allowed -- Highest volume allowed
-- DEFAULT VALUE: 512 -- DEFAULT VALUE: 1.5
config.HIGHEST_VOLUME = 512 config.HIGHEST_VOLUME = 1.5
-- Ratio that must be met or exceeded to trigger a song skip. -- Ratio that must be met or exceeded to trigger a song skip.
-- DEFAULT VALUE: 0.5 -- DEFAULT VALUE: 0.5
@ -80,7 +80,7 @@ config.ENABLE_ADMINS = true
-- commands. -- commands.
-- EXAMPLE: -- EXAMPLE:
-- config.ADMINS = {"Matt", "Matthieu"} -- config.ADMINS = {"Matt", "Matthieu"}
config.ADMINS = {"Matt"} config.ADMINS = {"Matt", "DrumZ"}
-- Make add an admin command? -- Make add an admin command?
-- DEFAULT VALUE: false -- DEFAULT VALUE: false
@ -133,6 +133,9 @@ config.NO_ARGUMENT = "The command you issued requires an argument and you did no
-- Message shown to users when they try to change the volume to a value outside the volume range. -- Message shown to users when they try to change the volume to a value outside the volume range.
config.NOT_IN_VOLUME_RANGE = "The volume you tried to supply is not in the allowed volume range. The value must be between " .. config.LOWEST_VOLUME .. " and " .. config.HIGHEST_VOLUME .. "." config.NOT_IN_VOLUME_RANGE = "The volume you tried to supply is not in the allowed volume range. The value must be between " .. config.LOWEST_VOLUME .. " and " .. config.HIGHEST_VOLUME .. "."
-- Message shown to users when they successfully change the volume.
config.VOLUME_SUCCESS = "You have successfully changed the volume to the following: " .. config.VOLUME .. "."
---------------------- ----------------------
-- HTML CONFIGURATION -- HTML CONFIGURATION

View file

@ -16,7 +16,6 @@ from os import remove, system
from time import sleep from time import sleep
url = argv[1] url = argv[1]
volume = argv[2]
video = pafy.new(url) video = pafy.new(url)
try: try:
@ -31,7 +30,7 @@ while isfile('song.ogg.temp'):
sleep(1) sleep(1)
if isfile('song.ogg'): if isfile('song.ogg'):
system('ffmpeg -i song.ogg -acodec libvorbis -ar 48000 -ac 1 -loglevel quiet -vol ' + str(volume) + ' song-converted.ogg -y') system('ffmpeg -i song.ogg -acodec libvorbis -ar 48000 -ac 1 -loglevel quiet song-converted.ogg -y')
else: else:
with open('.video_fail', 'w+') as f: with open('.video_fail', 'w+') as f:
f.close() f.close()

View file

@ -80,8 +80,9 @@ function parse_command(message)
if config.OUTPUT then if config.OUTPUT then
print(message.user.name .. " has changed the volume to the following: " .. argument .. ".") print(message.user.name .. " has changed the volume to the following: " .. argument .. ".")
if argument ~= nil then if argument ~= nil then
if config.LOWEST_VOLUME < tonumber(argument) < config.HIGHEST_VOLUME then if config.LOWEST_VOLUME <= tonumber(argument) and tonumber(argument) <= config.HIGHEST_VOLUME then
config.VOLUME = tonumber(argument) config.VOLUME = tonumber(argument)
message.user:send(config.VOLUME_SUCCESS)
else else
message.user:send(config.NOT_IN_VOLUME_RANGE) message.user:send(config.NOT_IN_VOLUME_RANGE)
end end
@ -294,7 +295,7 @@ end
-- Downloads/encodes the audio file and then begins to play it. -- Downloads/encodes the audio file and then begins to play it.
function start_song(info) function start_song(info)
os.execute("python download_audio.py " .. info.id .. " " .. config.VOLUME) os.execute("python download_audio.py " .. info.id)
if not file_exists(".video_fail") then if not file_exists(".video_fail") then
while not file_exists("song-converted.ogg") do while not file_exists("song-converted.ogg") do
os.execute("sleep " .. tonumber(2)) os.execute("sleep " .. tonumber(2))
@ -302,7 +303,7 @@ function start_song(info)
if piepan.Audio:isPlaying() then if piepan.Audio:isPlaying() then
piepan.Audio:stop() piepan.Audio:stop()
end end
piepan.me.channel:play("song-converted.ogg", get_next_song) piepan.me.channel:play({filename="song-converted.ogg", volume=config.VOLUME}, get_next_song)
else else
return false return false
end end