// Path: music-visualizer/src/main/java/org/onebeartoe/juke/javafx/demo/MusicVisualizerLedMatrixListener.java
// public class MusicVisualizerLedMatrixListener implements LedMatrixListener
// {
//     private Pixel pixel;
//     
//     private PixelEnvironment pixelEnvironment;
//     
//     public MusicVisualizerLedMatrixListener(PixelEnvironment environment)
//     {
//         pixelEnvironment = environment;
//     }
// 
//     @Override
//     public Pixel getPixel()
//     {
//         return pixel;
//     }
//     
//     @Override
//     public void ledMatrixReady(RgbLedMatrix matrix)
//     {        
//         pixel = new Pixel(pixelEnvironment.LED_MATRIX, pixelEnvironment.currentResolution);
//         pixel.matrix = matrix;
//         
//         scrollWelcomeMessage();
//         
//         // delay for a bit
//         Sleeper.sleepo(3000);
//         
//         pixel.stopExistingTimer();
//         
//         
//         
//     }
//     
//     private void scrollWelcomeMessage()
//     {
//         pixel.setScrollingText("Music Visualizer");
//         pixel.scrollText();
//     }
// }


import ioio.lib.api.exception.ConnectionLostException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.beans.binding.DoubleBinding;
import javafx.beans.binding.StringBinding;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.ListChangeListener;
import javafx.collections.ListChangeListener.Change;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Orientation;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.Slider;
import javafx.scene.effect.DropShadowBuilder;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.media.AudioSpectrumListener;
import javafx.scene.media.EqualizerBand;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.paint.Color;
import javafx.scene.paint.CycleMethod;
import javafx.scene.paint.LinearGradient;
import javafx.scene.paint.Stop;
import javafx.scene.shape.Line;
import javafx.scene.shape.LineBuilder;
import javafx.scene.text.Font;
import javafx.scene.transform.Rotate;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.stage.WindowEvent;
import javafx.util.Duration;
import javafx.util.Pair;
import org.onebeartoe.juke.javafx.demo.MusicVisualizerLedMatrixListener;
import org.onebeartoe.pixel.LedMatrixListener;
import org.onebeartoe.pixel.PixelEnvironment;
import org.onebeartoe.pixel.PixelIntegration;
import org.onebeartoe.pixel.hardware.Pixel;
            {
                if (!playList.getSongs().isEmpty())
                {
                    curreentSongIndex = 0;
                    play(curreentSongIndex);
                }
                else
                {
                    trackLabel.setText("No songs found");
                    timeLabel.setText("");
                    nameLabel.setText("");
                    if (mediaPlayer != null)
                    {
                        mediaPlayer.stop();
                        mediaPlayer.setAudioSpectrumListener(null);
                    }
                    for (int i = 0; i < 10; i++)
                    {
                        vuMeters[i].setValue(0);
                    }
                    leftVU.set(0);
                    rightVU.set(0);
                }
            }
        });
        // load initial playlist
        playList.load("http://ia600402.us.archive.org/11/items/their_finest_hour_vol1/their_finest_hour_vol1_files.xml");
// keep this commented call to load() so that we know how to add songs to the playlist        
//      playList.load("http://www.archive.org/download/their_finest_hour_vol3/their_finest_hour_vol3_files.xml");
        
// Path: music-visualizer/src/main/java/org/onebeartoe/juke/javafx/demo/MusicVisualizerLedMatrixListener.java
// public class MusicVisualizerLedMatrixListener implements LedMatrixListener
// {
//     private Pixel pixel;
//     
//     private PixelEnvironment pixelEnvironment;
//     
//     public MusicVisualizerLedMatrixListener(PixelEnvironment environment)
//     {
//         pixelEnvironment = environment;
//     }
// 
//     @Override
//     public Pixel getPixel()
//     {
//         return pixel;
//     }
//     
//     @Override
//     public void ledMatrixReady(RgbLedMatrix matrix)
//     {        
//         pixel = new Pixel(pixelEnvironment.LED_MATRIX, pixelEnvironment.currentResolution);
//         pixel.matrix = matrix;
//         
//         scrollWelcomeMessage();
//         
//         // delay for a bit
//         Sleeper.sleepo(3000);
//         
//         pixel.stopExistingTimer();
//         
//         
//         
//     }
//     
//     private void scrollWelcomeMessage()
//     {
//         pixel.setScrollingText("Music Visualizer");
//         pixel.scrollText();
//     }
// }


// Path: music-visualizer/src/main/java/org/onebeartoe/fxexperienceplayer/FxExperiencePlayer.java
import ioio.lib.api.exception.ConnectionLostException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.beans.binding.DoubleBinding;
import javafx.beans.binding.StringBinding;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.ListChangeListener;
import javafx.collections.ListChangeListener.Change;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Orientation;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.Slider;
import javafx.scene.effect.DropShadowBuilder;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.media.AudioSpectrumListener;
import javafx.scene.media.EqualizerBand;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.paint.Color;
import javafx.scene.paint.CycleMethod;
import javafx.scene.paint.LinearGradient;
import javafx.scene.paint.Stop;
import javafx.scene.shape.Line;
import javafx.scene.shape.LineBuilder;
import javafx.scene.text.Font;
import javafx.scene.transform.Rotate;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.stage.WindowEvent;
import javafx.util.Duration;
import javafx.util.Pair;
import org.onebeartoe.juke.javafx.demo.MusicVisualizerLedMatrixListener;
import org.onebeartoe.pixel.LedMatrixListener;
import org.onebeartoe.pixel.PixelEnvironment;
import org.onebeartoe.pixel.PixelIntegration;
import org.onebeartoe.pixel.hardware.Pixel;

            {
                if (!playList.getSongs().isEmpty())
                {
                    curreentSongIndex = 0;
                    play(curreentSongIndex);
                }
                else
                {
                    trackLabel.setText("No songs found");
                    timeLabel.setText("");
                    nameLabel.setText("");
                    if (mediaPlayer != null)
                    {
                        mediaPlayer.stop();
                        mediaPlayer.setAudioSpectrumListener(null);
                    }
                    for (int i = 0; i < 10; i++)
                    {
                        vuMeters[i].setValue(0);
                    }
                    leftVU.set(0);
                    rightVU.set(0);
                }
            }
        });
        // load initial playlist
        playList.load("http://ia600402.us.archive.org/11/items/their_finest_hour_vol1/their_finest_hour_vol1_files.xml");
// keep this commented call to load() so that we know how to add songs to the playlist        
//      playList.load("http://www.archive.org/download/their_finest_hour_vol3/their_finest_hour_vol3_files.xml");
        
        ledPanelListener = new MusicVisualizerLedMatrixListener(pixelEnvironment);