Dectect Audio playing function?

Started by MrFlambo, Feb 24, 2020, 01:25 AM

Previous topic - Next topic

MrFlambo

Recently I have started coding an auto jukebox player and shuffler using computercraft, but when I try to find a way to detect whether the computer is playing a sound or not I can't seem to find one. Is there something I am missing or is it just not possible?

Lupus590

Computercraft has no way on its own to detect sound

You could time the sounds and use a timer event to signify the end

SquidDev

Just to expand on what Lupus says, the issue here is that the server doesn't know how long any sound is. When you play a sound, all we do is send a message to all players saying "Play minecraft:ding" (or whatever) - everything else is handled by the client.

More crucially, the server cannot know how long any sound is - sounds can be overridden by resource packs, so every player could be listening to a different song (even if this is rather unlikely).

As lupus says, sadly the easiest thing to do here is just to hard code the default lengths.
GitHub | CC:Tweaked: A ComputerCraft fork | Plethora: A peripheral mod

MrFlambo

Sadly the timing of the audio is not an option due to variations in tick speed on my server so even though I have the sleep command waiting for the right amount of time it can vary from 5 times to 2 time the right amount of time.
But thanks anyways.

Lupus590

Quote from: MrFlambo on Feb 24, 2020, 07:22 PM...due to variations in tick speed on my server... it can vary from 5 times to 2 time the right amount of time.

sounds like an overloaded server, how do you play if it's that bad?

MrFlambo

#5
Its not that laggy with ping just the tickspeed. For some reason the tickspeed just likes to fluctuate which makes the sleep and timer commands hard to use.
Also a way I could combat this is by using some sort of tickspeed math, so is there a variable that refers to the tickspeed? I'm sure I could probably make an equation to have it wait a certain amount of time by using tickspeed.