Iron Curtain

From SlugWiki
Revision as of 22:30, 25 August 2015 by Ivanaf (Talk | contribs) (15 revisions imported)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
A prototype of the Iron Curtain displaying a traveling wave.

Overview

An LED display built out of LED boards from some dead guy at TEP.

XMMS Plugin

Use the functions in xmms-1.2.11/libxmms/xmmsctrl.h to get data other than frequency and PCM data. Useful functions include:

gint xmms_remote_get_output_time(gint session);
gint xmms_remote_get_playlist_length(gint session);
gchar *xmms_remote_get_playlist_file(gint session, gint pos);
gchar *xmms_remote_get_playlist_title(gint session, gint pos);
gint xmms_remote_get_output_time(gint session);
gboolean xmms_remote_is_playing(gint session);
gboolean xmms_remote_is_paused(gint session);
gboolean xmms_remote_is_shuffle(gint session);
gboolean xmms_remote_is_repeat(gint session);
int xmms_remote_get_main_volume(gint session);
int xmms_remote_get_balance(gint session);
int xmms_remote_get_playlist_pos(gint session);

The format of the data streamed from the XMMS Plugin to user programs via named pipes is given below. There are two types of data streamed to the pipes: Information data about the state of XMMS and frequency data from the playing song. Each chunk is preceded by an id number followed by the bytes of relevant data. Frequency data is sent much more often than information data. Information data is only sent if one of the title, pause status, play status, shuffle status, repeat status, volume or balance changes.

Frequency Data:
4 bytes (int32): Id, which is 1 for frequency data
4 bytes (int32): time into song in milliseconds
512 bytes (int16): the 256 frequency values for channel 0
512 bytes (int16): the 256 frequency values for channel 1

Information Data:
4 bytes (int32): Id, which is 2 for information data
4 bytes (int32): tb, the number of bytes in title
tb bytes (char): the title of the currently playing song
4 bytes (int32): is_paused. 1 if true, else 0.
4 bytes (int32): is_playing. 1 if true, else 0.
4 bytes (int32): is_shuffle. 1 if true, else 0.
4 bytes (int32): is_repeat. 1 if true, else 0.
4 bytes (int32): volume, [0,100]
4 bytes (int32): balance, [-100 (all left),100 (all right)]
  • Note the streamed data is little endian, meaning the int32 ABCDEF12 would be sent as the following bytes: 12 EF CD AB

Stay tuned for PCM data!

Sample parser. It's not very talented yet.

import java.io.*;

public class ReadTest{

  public static void main(String[] args){

    try{

      System.out.println("step 1");

      FileInputStream stream = new FileInputStream(new File("/home/hl/lyric/xmms-pipes/YOUR_PIPE_NAME"));
      
      System.out.println("step 2");

      while(true){
          byte[] b = new byte[4];
          int temp = stream.read(b);

          if(temp == -1){
              break;
          }

          if(b[0] == 1){
              // time and song data
              byte[] timeBytes = new byte[4];
              stream.read(timeBytes);
              byte[] data = new byte[512];
              byte[] data2 = new byte[512];
              stream.read(data);
              stream.read(data2);
          }else if(b[0] == 2){
              // info data
              stream.read(b);
              // b[0] holds the number of chars in the song name
              byte[] data = new byte[b[0] + 24];
              stream.read(data);

              for(int i = 0 ; i < b[0] ; i++){
                  // prints out song name
                  System.out.print(((char)data[i]) + " ");
              }
              System.out.println();

          }else{
              System.out.println("you were fubarred!");
          }
      }
    }catch(Exception e){
        System.out.println("snafu :(");
    }

  }
}


Each named pipe should have only one user. The current named pipes are given below. Contact Lyric if you want one.

Pipe Name User
magical_trevor lyric
corn_cob arwest
hash_pipe natech
fireworks emarion, wrchan