////////////// methods to create the interactive visualizer ////////////////////////
  private void createMainFrame() {
    mainFrame = new JFrame();
    mainFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    Container contentPane = mainFrame.getContentPane();
    // contentPane.setLayout(new BorderLayout());

    // creates the control panel
    controlPanel = new JPanel(null);
    controlPanel.setLayout(new FlowLayout());
    makeSoundVis();
    mainFrame.addComponentListener(new ResizeHandler());

    // setting up the play sound button
    playBtn = new JButton("Play");
    playBtn.setEnabled(true);
    playBtn.setToolTipText("Play the  sound");
    playBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            stopBtn.setEnabled(true);
            pauseBtn.setEnabled(true);
            playBtn.setEnabled(false);
            playSelectionBtn.setEnabled(false);
            zoomInBtn.setEnabled(false);
            zoomOutBtn.setEnabled(false);
            isPlaying = true;
            myHelper.play();
          }
        });
    controlPanel.add(playBtn);

    // setting up the play selection button
    playSelectionBtn = new JButton("Play Selection");
    playSelectionBtn.setEnabled(false);
    playSelectionBtn.setToolTipText("Play sound between start and stop index");
    playSelectionBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            playSelClicked++;
            stopBtn.setEnabled(true);
            pauseBtn.setEnabled(true);
            playSelectionBtn.setEnabled(false);
            playBtn.setEnabled(false);
            zoomInBtn.setEnabled(false);
            zoomOutBtn.setEnabled(false);
            isPlaying = false;
            if (playSelClicked == 1) {
              myHelper.playInRange(
                  wavePanel.getSelectionStartSample(), wavePanel.getSelectionEndSample());
            } else {
              myHelper.play();
            }
          }
        });
    controlPanel.add(playSelectionBtn);

    // setting up the stop button
    stopBtn = new JButton("Stop");
    stopBtn.setEnabled(false);
    stopBtn.setToolTipText("Stop playing the sound");
    stopBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            myHelper.stop();
            stopBtn.setEnabled(false);
            pauseBtn.setEnabled(false);
            playBtn.setEnabled(true);
            if (wavePanel.moreZoomInScope()) {
              zoomInBtn.setEnabled(true);
              playSelectionBtn.setEnabled(true);
            }

            if (wavePanel.moreZoomOutScope()) {
              zoomOutBtn.setEnabled(true);
            }
            playSelClicked = 0;
            isPlaying = false;
          }
        });
    controlPanel.add(stopBtn);

    // setting up the stop button
    pauseBtn = new JButton("Pause");
    pauseBtn.setEnabled(false);
    pauseBtn.setToolTipText("Pause the sound");
    pauseBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            myHelper.pause();
            if (isPlaying) {
              playBtn.setEnabled(true);
            } else {
              playSelectionBtn.setEnabled(true);
            }
          }
        });
    controlPanel.add(pauseBtn);

    // setting up the zoom  button
    zoomInBtn = new JButton("Zoom In");
    zoomInBtn.setEnabled(false);
    zoomInBtn.setToolTipText("Click to see the samples within your selection");
    zoomInBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            handleZoomIn();
          }
        });
    controlPanel.add(zoomInBtn);

    // setting up the zoom  button
    zoomOutBtn = new JButton("Zoom Out");
    zoomOutBtn.setEnabled(false);
    zoomOutBtn.setToolTipText("Click to zoom out");
    zoomOutBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            handleZoomOut();
          }
        });
    controlPanel.add(zoomOutBtn);

    controlPanel.setBounds(0, controlLocY, frameWidth, controlHeight);
    contentPane.add(controlPanel);

    contentPane.add(wavePanel);
    contentPane.add(overViewPanel);
    wavePanel.setBounds(0, waveLocY, frameWidth, waveHeight);

    // controlPanel.removeAll();
    // controlPanel.setBackground(Color.CYAN);

    mainFrame.setSize(frameWidth, frameHeight);

    overViewPanel.init();
    wavePanel.init();
    //
    // mainFrame.pack();
    // mainFrame.setResizable(false);
    // mainFrame.validate();

    mainFrame.setVisible(true);
    overViewPanel.setBounds(0, 0, frameWidth, overViewHeight);

    // mainFrame.validate();

  }
 private void makeOverView() {
   overViewPanel = new OverViewPanel();
   overViewPanel.setPreferredSize(new Dimension(frameWidth, overViewHeight));
   overViewPanel.setSize(overViewPanel.getPreferredSize());
 }
 /*
  * This method is called to refresh the visualization and optionally update
  * the byte array in helper with the current content of the integer arraylist.
  */
 public void refresh(boolean updateData) {
   wavePanel.refresh(updateData);
   overViewPanel.refresh();
 }