music-sync

module
v0.0.0-...-62b9041 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2020 License: MIT

README

Build Status Coverage Status Codacy Grade Code Climate Issues Code Climate Maintainability GitHub Release Version GoDoc Reference License

Music Sync

A go application to play the same music on multiple devices at once. It works best when all playing devices are similar, to avoid differences in the time it takes the audio to be played. I usually test the timing with two Windows 7 machines, one x64, one x86 to ensure the timing difference between the devices is small enough that hearing 2 different devices playing music sounds like one.

Installation

To install do go get github.com/LogicalOverflow/music-sync/... or download the executable from the latest release.

Getting Started

After installing, create a directory named audio and put your audio files into it. Also, create a users.json containing at least one username and password/public key of your choice:

{
    "username": {
        "password": "a password",
        "pubKey": "a public key formatted for use in the SSH wire protocol (RFC 4253, section 6.6)"
    }
 }

If you want, you can add lyrics information to your songs. To add lyrics to a song called song.mp3, create a file called song.mp3.json next to the mp3 file containing the lyrics:

[
    [
        {
            "timestamp": 1234,
            "caption": "The first "
        },
        {
            "timestamp": 5678,
            "caption": "line of lyrics."
        }
    ],
    [
        {
            "timestamp": 9101,
            "caption": "The second "
        },
        {
            "timestamp": 10112,
            "caption": "line."
        }
    ]
]

Here, timestamps are in milliseconds from the start of the song, each array describes a line of lyrics and each object in those arrays a word/phrase/syllable in the lyrics.

Then you can start a local music-sync-server using music-sync-server. By default, this server listens on 127.0.0.1:13333 (--address, --port) for clients and provides a ssh terminal on 127.0.0.1:13334 (--ssh-address, --ssh-port) to control the server. By default, the server checks in it's working directory for a file called id_rsa to use as a host key (--host-key-file). If this file is not found a new host key is generated on every startup. For more options check music-sync-server --help.

To start a player use music-sync-player. By default this tries to connect to a server at 127.0.0.1:1333 (--address, --port). For more options check music-sync-player --help.

To get information about the current song playing and lyrics (if provided) in a terminal UI, you can use music-sync-infoer. By default this tries to connect to a server at 127.0.0.1:1333 (--address, --port). For more options check music-sync-infoer --help.

The ssh terminal on the server is used to control the server. The usernames and passwords are read from users.json (--users-file). You can manage the current playlist, pause and resume playback and set the playback volume for all clients. These commands are available:

  • queue filename [position] - Adds filename to the playlist at position or the end. You can use glob patterns to add multiple files.
  • remove position - Removes the song at position from the playlist
  • jump position - Jumps to position in the playlist, interrupting the current song
  • playlist - Prints the current playlist
  • pause - Pauses playback
  • resume - Resumes playback
  • volume volume - Sets the playback volume for all clients (volume should be between 0 and 1)
  • help [command] - Prints all commands or information and usage of command
  • ls [sub-directory] - Lists all songs in the music (sub-)directory
  • clear - Clears the terminal
  • exit - Closes the connection

Spaces in commands can be escaped using \ . To escape a backslash before a space use \\ , otherwise the backslash does not need to be escaped.

Directories

Path Synopsis
cmd
Package cmd provides utilities used to create the different command line interfaces
Package cmd provides utilities used to create the different command line interfaces
music-sync-infoer
This package is the main package of the music-sync player
This package is the main package of the music-sync player
music-sync-player
This package is the main package of the music-sync player
This package is the main package of the music-sync player
music-sync-server
This package is the main package of the music-sync server
This package is the main package of the music-sync server
Package comm contains functions and types from communication between music-sync clients and the server Package comm is a generated protocol buffer package.
Package comm contains functions and types from communication between music-sync clients and the server Package comm is a generated protocol buffer package.
Package log provides utilities for logging
Package log provides utilities for logging
Package playback contains functions and types to stream and play audio
Package playback contains functions and types to stream and play audio
Package schedule contains methods to start different types of clients/servers
Package schedule contains methods to start different types of clients/servers
ssh
Package ssh contains the ssh control interface
Package ssh contains the ssh control interface
Package timing provides functions to access raw and synced time with nanosecond precision
Package timing provides functions to access raw and synced time with nanosecond precision
Package util contains utility types and functions
Package util contains utility types and functions

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL