Comments (10)
You could always calculate the delay between each packet by doing something like this.
client:hook("OnUserStartSpeaking", function(client, user)
user.last_spoke = mumble.gettime()
end)
client:hook("OnUserSpeak", function(client, event)
local t = mumble.gettime()
local user = event.user
-- Round to nearest tenth
local delay = math.floor((t - user.last_spoke) * 100 + 0.5) / 100
-- delay = time between each packet
user.speech_delay = delay
user.last_spoke = t
end)
client:hook("OnUserStopSpeaking", function(client, user)
print("User spoke with a delay of", user.speech_delay)
end)
from lua-mumble.
Hey, so I also just pushed a commit to fix a bug where OnUserStartSpeaking and OnUserStopSpeaking could potentially not be called if the user only sent 1 frame of audio data. This can happen if a user presses their push to talk button really fast.
Also, for calculating the delay, it may be better to use the highest delay value during the transmission.
client:hook("OnUserStartSpeaking", function(client, user)
user.last_spoke = mumble.gettime()
user.speech_delay = 0
end)
client:hook("OnUserSpeak", function(client, event)
local t = mumble.gettime()
local user = event.user
-- Round to nearest tenth
local delay = math.floor((t - user.last_spoke) * 100 + 0.5) / 100
-- delay = time between each packet
if delay > user.speech_delay then
-- Only update the delay value when it's higher than the last value
user.speech_delay
end
user.last_spoke = t
end)
client:hook("OnUserStopSpeaking", function(client, user)
print("User spoke with a delay of", user.speech_delay)
end)
I found that sometimes the delay can be sometimes be low on the last transmitted frame, which is perfectly fine, but could cause your value to be lower than it should.
from lua-mumble.
There's not a real easy way to do this. The client just accepts the voice packets as they come, so it doesn't actually know the rate in which they are received.
from lua-mumble.
Very recently, in the plugins WIP branch, an addition was made that exposes this information:
mumble-voip/mumble@41244d7
So, somewhere it must be hidden... Sorry that i have not much more information :(
from lua-mumble.
Sample rate is not the same as the time between each packet. Sample rate is the quality of the audio.
Actually I'm dumb. I haven't been messing with this mumble stuff for a bit. Even still, there's no way for me to tell what the sample rate is just from the voice packets it receives alone. There has to be more to that commit you linked, because the information has to come from somewhere.
from lua-mumble.
From what I can tell, they end up passing SAMPLE_RATE define to those calls, which is defined as 48000, so I don't think that value even helps you here either.
https://github.com/mumble-voip/mumble/blob/41244d7df41651876033e227d8ef625bf38ca839/src/mumble/AudioOutput.cpp#L530
https://github.com/mumble-voip/mumble/blob/3d7f8cc4e5f502652f6660822eb791cec79a61f7/src/mumble/Audio.h#L18
from lua-mumble.
so I don't think that value even helps you here either.
I hoped there would be some magic formula to calculate the spacing... and unfortunately, i have no clue about PCM and audio sampling :(
from lua-mumble.
I will try that soon, thank you very much!
from lua-mumble.
Cool, thanks!!!
from lua-mumble.
Just for the archives, it works.
I however record all seen delays into an array and then take the average from that to smooth out possible excess values. The result gets rounded to the nearest tenth like coded above. That seems to work very reliably.
-- record timings between voice packets to determine the sampling speed
local time = mumble.getTime()
local delay = time - (remote.last_spoke or time)
remote.last_spoke = time
if delay > 0 then
if not remote.record_delay then
remote.record_delay = {delay}
else
remote.record_delay[#(remote.record_delay)+1] = delay
end
end
-- calculate the packet speed
local calculated_packet_speed = 0.02 -- mumbles default setting
if #(remote.record_delay) > 0 then
calculated_packet_speed = math.average(remote.record_delay)
calculated_packet_speed = math.floor(calculated_packet_speed * 100 + 0.5) / 100 -- round to nearest tenth
end
fgcom.dbg("calculated packet per audio: "..calculated_packet_speed)
from lua-mumble.
Related Issues (20)
- client.me object absent
- Compilation error from duplicate packet_handler definitions HOT 6
- Private message event HOT 1
- Question: How to capture incoming audio stream? HOT 20
- Implement pluginData sending function HOT 6
- timer.c realloc(): invalid next size HOT 41
- hook onUserChannel() not called? HOT 2
- uninitialized error variable in client_play() HOT 3
- client_isPlaying channel taken from incorrect argument
- Played samples not audible after some time (client:transmit) HOT 13
- client:play() arguments? HOT 3
- Hook:OnMessage HOT 5
- sendPluginData with list broken? `bad argument #3 to 'sendPluginData' (mumble.user expected, got table)` HOT 25
- How to compile? HOT 19
- Stuttery Audio playback HOT 9
- Timer counter HOT 1
- Crash in timer.lua example script HOT 7
- Typo in README.md (mumble.user:isMuted()) and non-working mumble.user:isSelfMute() HOT 2
- Add plugin packets HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lua-mumble.