Announcement

Collapse
No announcement yet.

Project: Perfect Sync of Winamp3 over LAN

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Project: Perfect Sync of Winamp3 over LAN

    Certainly this is not a new idea, but I haven't seen anyone go all out with it yet (sorry if I just didn't look hard enough). At school, we throw a lot of parties and we like the same music blasting from every room. To do that I need all the computers in my house play music in perfect sync and stay in perfect sync. Already developed, we could use ShoutCast, but then each stream is a few seconds out of sync. There's also NetSync for 2.x, which I haven't actually tried but I've heard looses sync after a couple songs (please tell me if this is not the case). Anyway, I'd like to start an open-source project designing a perfectly synced Winamp across a LAN and am calling upon Winamp community to help with ideas, the high-level design and perhaps the implementation.

    Some thoughts on making the sound sync:
    What I know is that when I use ShoutCast, the streams are off, but why? There are several buffers in the system that cause delay but I have no idea which would cause a significant difference in different computers.

    There's the network delay which could be brought down significantly by forgeting about TCP and using UDP broadcast (or multicast if practical) to send just one packet to multiple clients on the LAN. Every computer would get the same real-time data within milliseconds of each other. It's also possible the network delay is just caused by the packets being too big.

    There's the Winamp buffering delay. Here's an area where I'm really in the dark. Will faster computers buffer less, simply because they can? If so, if there's hooks within Winamp, it should be possible and not all that hard to sync the clocks on everyone's computer. Then you could simply have a massive buffer controlled by time.

    Lastly, there's the sound card delay. If the time it takes for a sound packet to propagate through the card causes more than a half-second difference between cards, then I may just bail on this idea all together, because I can think of no generic way to sync everyone's sound card. That'd be a royal pain. The only hack I can think of is to calibrate your Winamp by listening to the room next to you and adjusting a delay till they sound okay and then hope they stay in sync.

    So I'm looking for feedback. If you've tried to sync and know it's just about impossible to make perfect, please tell me and save me some time.

    If it turns out it is possible...
    In Winamp3, where's the hook to for a component to pull out the sound packet before it plays (and likewise where I can drop one in)?

    Let me know if you'd like to help develop in this project. I have plenty more ideas that follow up syncing that would require more people if you want to see every feature before Winamp4:
    sync each playlist
    allow any computer to modify the playlist, and change songs
    access permissions so that you and your roommates can change songs anywhere, but some drunk won't clear a massive playlist you set up.
    keychain remote Winamp, so that you don't have to get off your lazy ass to skip a bad song or turn up the tunes.

  • #2
    Alright, so two seconds after I posted I saw the FAQ. oops. For some reason, I was thinking sound was like video game updates where you just apply the most recent update as soon as you get it.

    Instead of syncing the sound packets, maybe the way to go with this is syncing the control signals like 'play' and 'next'. For every song, at about 3 seconds before the end of the song, have the server send out a 'next' signal and have every winamp crossfade to the next song. Or, without crossfading, have each client wait till the end of the song, send a signal to the server that it is DONE. When the server gets the DONE signal from everyone, you start up the next song (and obviously this can be optimized, by starting the sync just before the end of the song, but you get my point).

    What do ya think? Should I just stop posting?

    Comment


    • #3
      you're right it isn't a bad idea, however at the same token, it would never be perfectly in sync no matter how hard u try; and therefore it would sound like shit

      Comment


      • #4
        hey, no too bad. and if you could get it within even 50ms sync, itll be good. cause i mean, i got a prog thatll delay my rear speakers output by aprox 50ms, and it just makes a small echo type effect. it aint that bad.

        one way to get nearly perfect sync on all computer, this is gonna be a bit tricky, but i think itll work... if while winamp is playing, it also has the sync component recording the wave output, this was its for perfect sync with the sound card, and therefor can adjust forwards or backwards the audio as needed.
        -=- Darkain Dragoon -=-
        -=- RM-X Home Page - Controlling Winamp via RM-900, RM-1000, RM-1500, ATI Remote Wonder, Joysticks, Gamepads, Wheels, Keyboard shortcuts, Multimedia keyboards, across the net, and much more! -=- Defenestration !!! -=-

        Comment


        • #5
          there is a way that I can think *might* work, but I kinda doubt it
          if you had the plugin sync up the times of each and every computer that would be participating; then you could have your plugin send out a signal that would tell them to buffer x song, and start playing exactly 1 second after the signal was sent (in the signal you would give the time, not just 1 second after); that theoretically should work

          however synching up even 2 computers to be anywhere less than 100ms (just the system time) is quite an accomplishment in itself

          Comment


          • #6
            If this is all in one house (did I catch that right??) Then there is another way to get around this. If you hook all the speakers in the house up to one computer, then they would all be synced. This might require running through an amplifier I'm not familier with how far signals run efficiently in these settings. Then, if you have an RF remote (NOT an IR remote) hooked into winamp, then you can control playback from anywhere in the house (RF remotes work up to about 100 feet away and they transmit through walls and ceilings).
            Turtle Beach offers a stand alone RF remote. It's meant to work with thier proprietary software but might be able to work. Streamzap also offers a remote as does ATI . Find more here.
            If you have other computers where you want to change the playlists etc. alongside using the RF remote here are some options:
            Winamp 2 remote control plugins
            Or you could use a VNC
            There are some interesting conversations In these threads

            Hope this helps and again I'm not saying don't do it your way but giving an alternative. Please any corrections or comments to what I've said are appreciated.

            Comment


            • #7
              The idea of waiting for the winamp buffer to load before playing is an important one. I don't know much about the SDK yet, but I somehow doubt there's a way to load the play buffer without actually playing the song. If there is, problem solved. If not, I'm thinkin all we need to do is start playing the song and then pausing it as soon as the time into the song is nonzero. Then you know the buffer is loaded and the server can send the unpause signal as soon as all the clients have reported that they are ready to go. Unfortunately, I also doubt that the granularity of time into each song is less than a second. My plan would only work if it were in milliseconds or less.

              Also, even though I said earlier that I wanted everything in *perfect* sync, I'd be content as long as they were within 100 ms, and never diverged after any amount of songs.

              In the path from when a playlist first sees a song to play, to where the sound packet is sent to the soundcard, could somebody post each point where a component can hook into the system?

              Comment


              • #8
                ok, well that could potentially be done like that; however you cannot have any crossfading on, and you'd have to set winamp to not automatically go to the next song, instead to stop after each and wait for the signal from the server to queue up the next song.

                Originally posted by Garious
                In the path from when a playlist first sees a song to play, to where the sound packet is sent to the soundcard, could somebody post each point where a component can hook into the system?

                u lost me there...

                Comment


                • #9
                  What I mean by hooks is places where the Winamp kernel will call the code in your component when a particular event happens. In the MAKI scripting language for winamp, there are hooks for every major event for the user interface. You can say:
                  onPlay() { do this }
                  onStop() { do that }

                  I'm wondering if there are similar hooks for components that allow to register functions with the kernel.

                  On top of the hooks that MAKI supports, we'd need more calls such as:
                  onPlaylistSeesNextSongIsUp (String song_name)
                  onPlayBufferFull ()
                  onPlayBufferEmpty ()
                  onPacketReadyToSendToSoundCard (Packet*)

                  Having calls like this (which may or may not already exist) allow you to write interrupt-driven software rather than polling for events or making synchronous calls (calls that don't return until the action in completed). It allows third-party developers to add extra goodies to the kernel as it goes through it's normal activity. MAKI does an excellent job with that, and I'm just wondering if the SDK has similar and more advanced features for components.

                  Comment


                  • #10
                    well, you'd hafta check std.mi and the sdk to find out what kind of calls wa3 supports and whatnot.......hrm, maybe this could be a way for me to jump into wa3 programming (I know programming, just not c++/maki)

                    ok, on running thru std.mi myself (and throughly convincing myself I really wanna learn wac programming), here's what I found. seemingly, onPlay registers when winamp3 begins playing and not when it begins buffering (i'd check but I'm not sure how right now). for onSystemSeesNextPlaylistItem I think, since (to my knowledge) there is no such thing, what you would have to do is take the next playlist item selecting into your own hands. you would check to see whether or not random was enabled, if it was select a random track, ir not then just select the next track in the playlist; then once you have arbitrarily decided what song will play, you can tell each client what song will be next, and have them remember that. then, once the server finishes a song, it will start the next song immediately, and use onPlay { pause }, at which time it would tell the rest of the servers to play and then do onPlay { pause }. after waiting a second or two, your server would tell each client to play, and a few ms later (you could somehow integrate a ping into the wac so that it knows approx how long to wait) begin playing itself



                    do I make any sense whatsoever??
                    Last edited by thepyr0x; 25 July 2002, 05:16.

                    Comment


                    • #11
                      I started looking through the SDK, and a lot of things are starting to look very possible.

                      I believe we can pull design this thing so it could do everything ShoutCast can do in addition to optionally syncing with those connected to you.

                      ...and so i began to architect.

                      Terms:
                      Client - a component in Winamp that plays what song it is told
                      Server - a component in Winamp that controls the playlist
                      and tells clients what to play

                      There is an important distinction between client and server in that the two components have no overlapping duties. If the instance of Winamp that is acting as the server wants to also play music, he must start a client component and have it register to its own IP.

                      The server will be extremely lightweight in that it will only broadcast control signals and URLs.
                      The client will be responsible for streaming the current and next song.

                      In sync-mode, the client will start filling a local file from the stream for the current song. After it has enough data to play and not run dry from a slow DL, it will send a signal to the server saying that it is ready. When everyone is ready, the server will send a message out to everyone saying to start playing the file. Assuming the connection stays stable, the file will continue to fill as the song is played. If the connection is fast enough, after a few seconds of playing the current song, a separate thread will start downloading the next song. This way, if you want to skip the current song, the client can immediately tell the server it's ready to play. This syncing will occur at the start of every song so that the sound card doesn't have enough time to throw things off.

                      In async-mode, the client will simply stream the URLs it's given and play them as soon as it can.

                      The details:
                      By doing this in *delayed-time* rather than real-time allows us to use all TCP which makes it so we can establish connection from inside a firewall, so long as the server is on a public IP (or within the firewall).

                      When the client establishes a connection with the server, the server will tell it to cross-fade or not and the cross-fading preferences. The client will save the old settings and apply the server's settings, which will remain while the client is connected.

                      Winamp3 hooks:
                      We need to find out how to capture the play and next events and then clear them so they cannot go through the rest of the system and actually play anything. As for now, we should also disable most other events such as jumping to the middle of the song.

                      The only other calls we need to make are getting the current and next song, as well as calling play which are all really simple.

                      I got to hand it to the Winamp3 development staff, the SDK code is beautiful. It looks to me that this project will be a breeze because of it.

                      The reason why I posted this architecture and didn't just go implement it is because I want to know what other people think of this strategy. If you think it'll work, let us know. If not, let us know. I'll open-source everything I write so if you're thinking of adding features on top of this, tell me now so I can make you some hooks into the code.

                      Lastly, my interest in this component is syncing Winamp. Therefore I will probably terribly lazy about putting any sort of decent GUI on top. If you'd like to help, I can do all the annoying networking and buffering stuff, and so the interface to Winamp and the GUI are up for grabs. Who's up for it?

                      -Greg

                      Comment


                      • #12
                        Garious + Greg = Gregarious???

                        gregarious \grih-GAIR-ee-us\, adjective:
                        1. Tending to form a group with others of the same kind.
                        2. Seeking and enjoying the company of others.

                        Is this on purpose?

                        Comment


                        • #13
                          (last post was before reading your lost post lol)

                          Anyway this sounds great. I'm not much help as far as coding goes bc I don't know C++ or Maki and frankly don't have the time right now.
                          You talk about differentiating between "client" and "server" well from what I gather about wasabi you might be able to compile it as a separate exe from winamp??? is this correct???
                          Also you might want to be able to disable any options on all the clients like shuffle , crossfade etc.

                          Comment


                          • #14
                            Yeah, the name is intentional. You're very bright. Here's a cookie

                            _____
                            / \
                            / * \
                            | * * |
                            | * |
                            \ * * /
                            \_____/

                            Comment


                            • #15
                              Drag, that looked great in reply window. I guess the text window is not the canvas of our imaginations. What can ya do?

                              Anyway, the client and server will be compiled as components separately from Winamp and loaded in as modules. They will each be, in a sense, plug-ins.

                              Comment

                              Working...
                              X
                              😀
                              🥰
                              🤢
                              😎
                              😡
                              👍
                              👎