ComputerCraft Forums

ComputerCraft => Ask a Pro => Topic started by: MrFlambo on Feb 24, 2020, 01:25 AM

Title: Dectect Audio playing function?
Post by: MrFlambo on Feb 24, 2020, 01:25 AM
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?
Title: Dectect Audio playing function?
Post by: Lupus590 on Feb 24, 2020, 09:25 AM
Computercraft has no way on its own to detect sound

You could time the sounds and use a timer event to signify the end
Title: Dectect Audio playing function?
Post by: SquidDev on Feb 24, 2020, 09:52 AM
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.
Title: Dectect Audio playing function?
Post by: MrFlambo on Feb 24, 2020, 07:22 PM
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.
Title: Dectect Audio playing function?
Post by: Lupus590 on Feb 24, 2020, 07:36 PM
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?
Title: Dectect Audio playing function?
Post by: MrFlambo on Feb 25, 2020, 01:00 AM
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.