-
|
I'm trying out CC:tweaks out for the first time, and after a while of messing around I've created a setup using rednet where a computer recieves decoded chunks of a song through broadcast and plays it on as many speakers as possible (only tried 2 for now though). I kind of understand the encode decode aspect, aside from the values provided in a table (which shows when printing), but what I would like to know is how these chunks actually work on a deeper level. This would help me for example understand how much of a song is playing, and I could implement a playbar on a monitor (just thinking ahead). I am also confused on the frequency of broadcasts and receiving messages, as the music sometimes cuts out (I make the broadcast pc sleep for 2.7 seconds, which play's the song continuously at the right speed, but still has the cutout issue). I'm still doing research but any help would be greatly appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
I guess there's several layers here:
Note that there's several intermediate buffers here (both on the client and on the server). This is designed to reduce stuttering (particularly if the server is lagging), but requires you to keep the buffers pretty full. I haven't seen your code, but if you're just sending one audio chunk at a time, I suspect you're never filling the buffers all the way, so what happens is the first chunk of audio is entirely exhausted, and then you send the next chunk! If you can, it's better to rely on the This all said, if you're trying to play audio across multiple speakers, that is really hard. If two speakers are out of sync by even a single tick, things can sound terrible, and there's some known but ill-understood issues with speakers (#1488, #2120, #1874), which doesn't help! |
Beta Was this translation helpful? Give feedback.
I guess there's several layers here:
DFPWM itself is documented on this page (slightly nicer typeset version here). Though the details should be largely irrelevant here — all you need to know is each byte of DFPWM data corresponds to 8 samples of audio, and thus$\frac{8}{48000} = \frac{1}{6000}$ seconds of audio.
The raw audio data: This bit of the wiki is probably the best introduction — this explains the basics of how audio is represented (PCM audio, etc...).
Fo…