// Path: libuosl/src/org/solhost/folko/uosl/libuosl/data/SLSound.java
// public class SLSound {
//     private final SLDataFile sound, soundIdx;
// 
//     public SLSound(String soundPath, String soundIdxPath) throws IOException {
//         this.sound = new SLDataFile(soundPath, false);
//         this.soundIdx = new SLDataFile(soundIdxPath, true);
//     }
// 
//     public class SoundEntry {
//         public long id;
//         public long unknown;
//         public String fileName;
//         public byte[] pcmData;
//     }
// 
//     public int getNumEntries() {
//         return soundIdx.getLength() / 12;
//     }
// 
//     public synchronized SoundEntry getEntry(int index) {
//         int idxOffset = index * 12;
//         soundIdx.seek(idxOffset);
// 
//         SoundEntry entry = new SoundEntry();
// 
//         long offset = soundIdx.readUDWord();
//         long length = soundIdx.readUDWord();
//         if(offset == -1 || length == -1) {
//             return null;
//         }
// 
//         entry.id = index;
//         entry.unknown = soundIdx.readUDWord();
//         sound.seek((int) offset);
//         entry.fileName = sound.readString(16);
//         sound.skip(24);
//         entry.pcmData = sound.readRaw((int) (length - 16 - 24));
// 
//         return entry;
//     }
// 
// }
// 
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/data/SLSound.java
// public class SoundEntry {
//     public long id;
//     public long unknown;
//     public String fileName;
//     public byte[] pcmData;
// }


import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.DataLine;
import javax.swing.AbstractListModel;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import org.solhost.folko.uosl.libuosl.data.SLSound;
import org.solhost.folko.uosl.libuosl.data.SLSound.SoundEntry;

        JPanel soundInfoPanel = new JPanel();
        soundInfoPanel.setLayout(new FlowLayout());
        soundLabel = new JLabel("0x0000");
        soundButton = new JButton("Play");
        soundInfoPanel.add(soundLabel);
        soundInfoPanel.add(soundButton);

        soundButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                playSound(soundList.getSelectedIndex());
            }
        });

        soundList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        soundList.addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                if(e.getValueIsAdjusting()) return;
                selectSound(soundList.getSelectedIndex());
            }
        });
        soundList.setSelectedIndex(0);

        add(new JScrollPane(soundList), BorderLayout.WEST);
        add(soundInfoPanel, BorderLayout.CENTER);
    }

    private void selectSound(int listIndex) {
        int id = soundList.getModel().getElementAt(listIndex).id;
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/data/SLSound.java
// public class SLSound {
//     private final SLDataFile sound, soundIdx;
// 
//     public SLSound(String soundPath, String soundIdxPath) throws IOException {
//         this.sound = new SLDataFile(soundPath, false);
//         this.soundIdx = new SLDataFile(soundIdxPath, true);
//     }
// 
//     public class SoundEntry {
//         public long id;
//         public long unknown;
//         public String fileName;
//         public byte[] pcmData;
//     }
// 
//     public int getNumEntries() {
//         return soundIdx.getLength() / 12;
//     }
// 
//     public synchronized SoundEntry getEntry(int index) {
//         int idxOffset = index * 12;
//         soundIdx.seek(idxOffset);
// 
//         SoundEntry entry = new SoundEntry();
// 
//         long offset = soundIdx.readUDWord();
//         long length = soundIdx.readUDWord();
//         if(offset == -1 || length == -1) {
//             return null;
//         }
// 
//         entry.id = index;
//         entry.unknown = soundIdx.readUDWord();
//         sound.seek((int) offset);
//         entry.fileName = sound.readString(16);
//         sound.skip(24);
//         entry.pcmData = sound.readRaw((int) (length - 16 - 24));
// 
//         return entry;
//     }
// 
// }
// 
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/data/SLSound.java
// public class SoundEntry {
//     public long id;
//     public long unknown;
//     public String fileName;
//     public byte[] pcmData;
// }


// Path: viewsl/src/org/solhost/folko/uosl/viewsl/SoundView.java
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.DataLine;
import javax.swing.AbstractListModel;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import org.solhost.folko.uosl.libuosl.data.SLSound;
import org.solhost.folko.uosl.libuosl.data.SLSound.SoundEntry;


        JPanel soundInfoPanel = new JPanel();
        soundInfoPanel.setLayout(new FlowLayout());
        soundLabel = new JLabel("0x0000");
        soundButton = new JButton("Play");
        soundInfoPanel.add(soundLabel);
        soundInfoPanel.add(soundButton);

        soundButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                playSound(soundList.getSelectedIndex());
            }
        });

        soundList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        soundList.addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                if(e.getValueIsAdjusting()) return;
                selectSound(soundList.getSelectedIndex());
            }
        });
        soundList.setSelectedIndex(0);

        add(new JScrollPane(soundList), BorderLayout.WEST);
        add(soundInfoPanel, BorderLayout.CENTER);
    }

    private void selectSound(int listIndex) {
        int id = soundList.getModel().getElementAt(listIndex).id;
        SoundEntry entry = sound.getEntry(id);