FFT algorithm for MP3 player equalizer

Hi

I am trying to make an equalizer for my mp3 player. I found a fft algorithm to find the frequency spectrum for 4096 long double [][] array in one of the forums but the function does not work properly. I know because I compare its results with the math lab抯 fft function. Also when I compare the equalizer with the win amp抯 equalizer it does not match. Does any one know an fft algorithm for real valued 4096 long double array? Also I am not sure which values of the frequency spectrum to display in the equalizer. Should I take the average of the sum of the values or should I take only specific values?

Thank you for your helps

PS: if any one interested I can send the working program and also the source code!!

[740 byte] By [EmreZorlua] at [2007-10-2 11:29:07]
# 1
There are other java FFT implementations on the net, why don't you try one of those?
RadcliffePikea at 2007-7-13 4:49:04 > top of Java-index,Other Topics,Algorithms...
# 2
hi,I am interested by your program since i am trying to write an mp3 to midi conversion software but i cannot find no fft algorithm.I 'd appreciate if u can post the source code.Thanks for your help
relmoa at 2007-7-13 4:49:04 > top of Java-index,Other Topics,Algorithms...
# 3

Sorry for the late answer.

I have been trying to find fft algorithms but they are too slow. It is almost impossible to hear the music. It slows down. The computation of fft takes too much time. Did you use any fft algorithms that you used and work properly.

For the second reply: It is not over yet. I was planning on posting my code after I finish the visual equalizer. But if you want I can post what I have done so far.

EmreZorlua at 2007-7-13 4:49:04 > top of Java-index,Other Topics,Algorithms...
# 4

My favourite published FFT is half way down the page http://sepwww.stanford.edu/oldsep/hale/FftL .

Note - there is no need to use the FFT on all the mp3 data. You just want to a set of samples every now and again (say every 0.25 seconds) and process them in a thread running outside your MP3 play thread.

sabre150a at 2007-7-13 4:49:05 > top of Java-index,Other Topics,Algorithms...
# 5
> My favourite published FFT is half way down the page> http://sepwww.stanford.edu/oldsep/hale/FftL .That's: http://sepwww.stanford.edu/oldsep/hale/FftLab.html; )
prometheuzza at 2007-7-13 4:49:05 > top of Java-index,Other Topics,Algorithms...
# 6

> > My favourite published FFT is half way down the

> page

> > http://sepwww.stanford.edu/oldsep/hale/FftL .

>

> That's:

> http://sepwww.stanford.edu/oldsep/hale/FftLab.html

> ; )

Thanks! I have no idea what caused the truncation (unless of course 'finger trouble')!

sabre150a at 2007-7-13 4:49:05 > top of Java-index,Other Topics,Algorithms...
# 7
BTW, Matlab uses the free FFTW library available at http://www.fftw.orgThere is a JNI binding for Java available on that site, but there's a bit more of a learning curve with that library than with the Java implementations. (Though it will likely be considerably faster).
RadcliffePikea at 2007-7-13 4:49:05 > top of Java-index,Other Topics,Algorithms...
# 8
I would really appreciate if you could post what you have done so far.Thanks
relmoa at 2007-7-13 4:49:05 > top of Java-index,Other Topics,Algorithms...
# 9
I would really appreciate if you could post what you have done so far.Thanks
relmoa at 2007-7-13 4:49:05 > top of Java-index,Other Topics,Algorithms...
# 10

This is the last version of my project please post some commands for my code. I know my code is a little bit messy but this is the first time I am using java.

package MP3Player;

import java.awt.Color;

import java.awt.Container;

import java.awt.Dimension;

import java.awt.Font;

import java.awt.Insets;

import java.awt.Point;

import java.awt.Rectangle;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.ItemEvent;

import java.awt.event.ItemListener;

import java.awt.event.MouseEvent;

import java.awt.event.MouseListener;

import java.io.BufferedWriter;

import java.io.File;

import java.io.FileWriter;

import java.io.IOException;

import java.util.Map;

import java.util.Vector;

import javax.sound.sampled.AudioFileFormat;

import javax.sound.sampled.AudioFormat;

import javax.sound.sampled.AudioInputStream;

import javax.sound.sampled.AudioSystem;

import javax.sound.sampled.BooleanControl;

import javax.sound.sampled.DataLine;

import javax.sound.sampled.FloatControl;

import javax.sound.sampled.SourceDataLine;

import javax.swing.JButton;

import javax.swing.JCheckBox;

import javax.swing.JComboBox;

import javax.swing.JFileChooser;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JList;

import javax.swing.JOptionPane;

import javax.swing.JPanel;

import javax.swing.JProgressBar;

import javax.swing.JScrollPane;

import javax.swing.JSlider;

import javax.swing.JTabbedPane;

import javax.swing.JTextArea;

import javax.swing.SwingConstants;

import javax.swing.event.ChangeEvent;

import javax.swing.event.ChangeListener;

import org.tritonus.share.sampled.file.TAudioFileFormat;

public class JavaMP3Player extends JFrame implements ActionListener, ChangeListener, ItemListener, MouseListener {

private JTabbedPane tabbedPane1;

private JPanel playListPane;

private JScrollPane playListSPane;

private JList playList1;

private JButton add_btn;

private JButton addFolder_btn;

private JButton delete_btn;

private JButton deleteAll_btn;

private JCheckBox shuffleCheck;

private JPanel panelEqu;

private JSlider equ0Slider;

private JSlider equ1Slider;

private JSlider equ2Slider;

private JSlider equ3Slider;

private JSlider equ4Slider;

private JSlider equ5Slider;

private JSlider equ6Slider;

private JSlider equ7Slider;

private JSlider equ8Slider;

private JSlider equ9Slider;

private JSlider panSlider;

private JComboBox equPreset;

private JLabel equPreLabel;

private JLabel db1Label;

private JLabel db0Label;

private JLabel db2Label;

private JLabel panlLabel;

private JLabel panrLabel;

private JLabel equnumLabel;

private JButton prev_btn;

private JButton play_btn;

private JButton pause_btn;

private JButton stop_btn;

private JButton next_btn;

private JProgressBar progressBar0;

private JProgressBar progressBar1;

private JProgressBar progressBar2;

private JProgressBar progressBar3;

private JProgressBar progressBar4;

private JProgressBar progressBar5;

private JProgressBar progressBar6;

private JProgressBar progressBar7;

private JProgressBar progressBar8;

private JProgressBar progressBar9;

private JProgressBar progressBar10;

private JProgressBar progressBar11;

private JProgressBar progressBar12;

private JProgressBar progressBar13;

private JProgressBar progressBar14;

private JProgressBar progressBar15;

private JSlider volumeSlider;

private JScrollPane scrollPane1;

private JTextArea MP3info;

private JSlider timeSlider;

private JCheckBox muteCheck;

private JLabel vol1Label;

private JLabel vol2Label;

private JLabel vol3Label;

private JLabel MP3infoLabel;

private JLabel grapEquLabel;

private JButton bogusButton;

private int count=0; // to find out which file from the list will be choosen

private int equ_count=0;

private int nextCount=-1;

private long fileLength, fileSizeByte, skipFileBytes = 0, skipFileBytesTemp = 0;

//fileLength = the duration of MP3 file found from the MP3 info

//fileSizeByte = the duration of MP3 file in BYTEs

//skipFileBytes = the BYTE that must be skiped learned from timeSlider

private Vector list = new Vector(1,1);

private Vector listName = new Vector (1,1);

private boolean statusPause=false, isMuted = false;

private String title, artist, presetNames[] = {"Normal", "Classical", "Club", "Dance", "Full Bass", "Full Treble", "Rock", "Techno"};

private String playListFiles[] = {};

//volatile boolean paused = false;

SourceDataLine line=null;

AudioInputStream din=null;

byte[] data = new byte[4096];

private boolean Mp3Ready = false;

int nBytesRead = 0;

int nBytesWritten = 0;

private boolean statusStoped=false;

double timeSec = 0, timeSecEskiler = 0, fileDuration=0;

double [] freqHistory = new double [16];

double gain = 0.5d;

float db = (float)(Math.log(gain)/Math.log(10.0)*20.0);

float[] equalizer;

float equ0=0, equ1=0, equ2=0,equ3=0,equ4=0,equ5=0,equ6=0,equ7=0,equ8=0,equ9=0;

float panContValue = 0;

//preset values

private int[] PRESET_NORMAL= {50,50,50,50,50,50,50,50,50,50};

private int[] PRESET_CLASSICAL= {50,50,50,50,50,50,30,30,30,24};

private int[] PRESET_CLUB= {50,50,58,66,66,66,58,50,50,50};

private int[] PRESET_DANCE= {74,66,54,50,50,34,30,30,50,50};

private int[] PRESET_FULLBASS= {74,74,74,64,54,38,24,22,22,22};

private int[] PRESET_FULLTREBLE={22,22,22,38,58,76,92,92,92,92};

private int[] PRESET_ROCK= {68,62,36,28,44,60,72,76,76,76};

private int[] PRESET_TECHNO= {70,66,52,34,36,52,70,76,76,72};

//slider variables

static final int gain_Min = 0;

static final int gain_Max = 10;

static final int gain_Init = 5;

static final int equ_Min = 0;

static final int equ_Max = 100;

static final int equ_Init = 50;

static final int pan_Min = -10;

static final int pan_Max = 10;

static final int pan_Init = 0;

static final int time_Min = 0;

static final int time_Max = 1000;

static final int time_Init = 0;

static final int prog_Min = 0;

static final int prog_Max = 100;

//

public JavaMP3Player(){

initComponents();

//exit_btn=new JButton("EXIT");

play_btn.setEnabled(false);

next_btn.setEnabled (false);

prev_btn.setEnabled(false);

stop_btn.setEnabled (false);

pause_btn.setEnabled(false);

play_btn.addActionListener(this);

next_btn.addActionListener(this);

prev_btn.addActionListener(this);

stop_btn.addActionListener(this);

pause_btn.addActionListener(this);

add_btn.addActionListener(this);

//exit_btn.addActionListener(this);

addFolder_btn.addActionListener(this);

delete_btn.addActionListener(this);

deleteAll_btn.addActionListener(this);

panSlider.addChangeListener(this);

panSlider.addMouseListener(this);

playList1.addMouseListener(this);

//

//progressBar0 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

//progressBar1 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

//progressBar2 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

//progressBar3 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

//progressBar4 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

//progressBar5 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

//progressBar6 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

//progressBar7 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

//progressBar8 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

//progressBar9 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

//progressBar10 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

//progressBar11 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

//progressBar12 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

//progressBar13 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

//progressBar14 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

//progressBar15 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

volumeSlider.addChangeListener(this);

muteCheck.addItemListener(this);

equ0Slider.addChangeListener(this);

equ1Slider.addChangeListener(this);

equ2Slider.addChangeListener(this);

equ3Slider.addChangeListener(this);

equ4Slider.addChangeListener(this);

equ5Slider.addChangeListener(this);

equ6Slider.addChangeListener(this);

equ7Slider.addChangeListener(this);

equ8Slider.addChangeListener(this);

equ9Slider.addChangeListener(this);

timeSlider.addChangeListener(this);

//

//equPreset = new JComboBox(presetNames);

//equPreset.setMaximumRowCount(5);

equPreset.addItemListener(this);

setResizable (false);

setBounds (100,100,642,263);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setVisible (true);

while (true){

try{

if (Mp3Ready){

//the playFile(int count) creates the line and when every component is ready

//the Mp3Ready is turned TRUE and the the read data will be written to the Line (thus to output to Speakers)

//the gain of the Line is created the gain is controled by a jslider called volumeSlider

FloatControl gainControl = (FloatControl)line.getControl(FloatControl.Type.MASTER_GAIN);

//the mute is a check box when the mute is TRUE independent of the gainControl the line is Muted.

BooleanControl muteControl = (BooleanControl)line.getControl(BooleanControl.Type.MUTE);

//the panControl control the balance between the right and left speaker, the mp3 does not need to be stereo

FloatControl panControl = (FloatControl)line.getControl(FloatControl.Type.PAN);

//EnumControl reverbControl = (EnumControl)line.getControl(EnumControl.Type.REVERB);

//reverbControl.setValue(ReverbType("concert", 1600, -1, 10.3, -0.7, 2.6));

//BooleanControl revrbControlSet = (BooleanControl)line.getControl(BooleanControl.Type.APPLY_REVERB);

//revrbControlSet.setValue(true);

//to reach the equlizer properties the of din (decoded input) properties are called

//the equlizer is controled by 10 sliders

if (din instanceof javazoom.spi.PropertiesContainer)

{

Map properties = ((javazoom.spi.PropertiesContainer) din).properties();

equalizer = (float[]) properties.get("mp3.equalizer");

}

//the data read from the din will be writen to line until a the end of stream

//when the end of Audiostrean is reached the nBytesRead becomes -1

while (nBytesRead != -1 && statusPause == false)

{

//int the while loop:

//while the data is writen to the line the states of the controles

//are controlled to realize any state changes

equalizer[0]=equ0;

equalizer[1]=equ1;

equalizer[2]=equ2;

equalizer[3]=equ3;

equalizer[4]=equ4;

equalizer[5]=equ5;

equalizer[6]=equ6;

equalizer[7]=equ7;

equalizer[8]=equ8;

equalizer[9]=equ9;

panControl.setValue(panContValue);

gainControl.setValue(db);

muteControl.setValue(isMuted);

//

//System.out.println(data[0]+"gir");

nBytesRead = din.read(data, 0, data.length); //the data is read from the decoded input

//System.out.println(data[0]);

timeSec = line.getMicrosecondPosition()/1000000; //calculates the amount of time left since the data is started to read

timeSec= timeSecEskiler + timeSec;// calculates the correct time for the mp3

if (!timeSlider.getValueIsAdjusting())

timeSlider.setValue(((int)((timeSec/fileDuration)*1000)));//the timeSlider is adjusted for every time the time chages

MP3info.setText("ARTIST: " + artist + "\n" + "TITLE : " + title + "\n"

+ "TIME : " + (int)(timeSec/60) + ":" + (int)(timeSec%60) + " of "

+ (int)(fileDuration/60) + ":" + (int)(fileDuration%60) );

if (nBytesRead != -1) //if the there is readable data write it to the line

{

nBytesWritten = line.write(data, 0, nBytesRead);

fft_1d(data);

}

}

if (statusStoped == false && ((int)((timeSec/fileDuration)*100)) >= 97) nextFile();

//the stop button makes nBytesRead equal to -1 so that it breakes the while loop

//then the statusStoped flag is checked if the user is stop the play or not

//if the mp3 is over the player is play the next song

}

Thread.sleep(100); //the player does noting for 100 miliseconds to decrease CPU usage

}

catch(Exception NoMP3) {

System.out.println("gote geldin " + NoMP3.toString());

}

}

}

public void mouseEntered(MouseEvent arg0) {

//TODO Auto-generated method stub

}

public void mouseExited(MouseEvent arg0)

{

//TODO Auto-generated method stub

}

public void mousePressed(MouseEvent arg0) {

//TODO Auto-generated method stub

}

public void mouseReleased(MouseEvent arg0) {

//TODO Auto-generated method stub

}

public void mouseClicked (MouseEvent event)

{

if(event.getSource() == playList1){

if (event.getButton() == 1 && event.getClickCount() == 2){

if(playList1.getSelectedIndex() != -1)

{

next_btn.setEnabled (true);

prev_btn.setEnabled(true);

stop_btn.setEnabled (true);

pause_btn.setEnabled(true);

count=playList1.getSelectedIndex();

if (line != null) stopFile();

statusPause = false;

playFile(count);

}

}

if (event.getButton() == 3 && event.getClickCount() == 2 && !(listName.isEmpty())){

nextCount = playList1.locationToIndex(event.getPoint());

playList1.setToolTipText("Enqueued Song: " + listName.get(nextCount));

//System.out.println(nextCount);

}

}

if(event.getSource() == panSlider){

if (event.getButton() == 1 && event.getClickCount() == 2)

panSlider.setValue(0);

}

}

public void itemStateChanged(ItemEvent event)

{

if (event.getSource() == muteCheck){

if (muteCheck.isSelected()) isMuted=true;

else if (!muteCheck.isSelected()) isMuted=false;

System.out.println(isMuted);

}

if (event.getSource() == equPreset && event.getStateChange() == ItemEvent.SELECTED){

System.out.println("1");

if (event.getItem() == "Normal")

{

equ0Slider.setValue(PRESET_NORMAL[0]);

equ1Slider.setValue(PRESET_NORMAL[1]);

equ2Slider.setValue(PRESET_NORMAL[2]);

equ3Slider.setValue(PRESET_NORMAL[3]);

equ4Slider.setValue(PRESET_NORMAL[4]);

equ5Slider.setValue(PRESET_NORMAL[5]);

equ6Slider.setValue(PRESET_NORMAL[6]);

equ7Slider.setValue(PRESET_NORMAL[7]);

equ8Slider.setValue(PRESET_NORMAL[8]);

equ9Slider.setValue(PRESET_NORMAL[9]);

}

if (event.getItem() == "Classical")

{

equ0Slider.setValue(PRESET_CLASSICAL[0]);

equ1Slider.setValue(PRESET_CLASSICAL[1]);

equ2Slider.setValue(PRESET_CLASSICAL[2]);

equ3Slider.setValue(PRESET_CLASSICAL[3]);

equ4Slider.setValue(PRESET_CLASSICAL[4]);

equ5Slider.setValue(PRESET_CLASSICAL[5]);

equ6Slider.setValue(PRESET_CLASSICAL[6]);

equ7Slider.setValue(PRESET_CLASSICAL[7]);

equ8Slider.setValue(PRESET_CLASSICAL[8]);

equ9Slider.setValue(PRESET_CLASSICAL[9]);

}

if (event.getItem() == "Club")

{

equ0Slider.setValue(PRESET_CLUB[0]);

equ1Slider.setValue(PRESET_CLUB[1]);

equ2Slider.setValue(PRESET_CLUB[2]);

equ3Slider.setValue(PRESET_CLUB[3]);

equ4Slider.setValue(PRESET_CLUB[4]);

equ5Slider.setValue(PRESET_CLUB[5]);

equ6Slider.setValue(PRESET_CLUB[6]);

equ7Slider.setValue(PRESET_CLUB[7]);

equ8Slider.setValue(PRESET_CLUB[8]);

equ9Slider.setValue(PRESET_CLUB[9]);

}

if (event.getItem() == "Dance")

{

equ0Slider.setValue(PRESET_DANCE[0]);

equ1Slider.setValue(PRESET_DANCE[1]);

equ2Slider.setValue(PRESET_DANCE[2]);

equ3Slider.setValue(PRESET_DANCE[3]);

equ4Slider.setValue(PRESET_DANCE[4]);

equ5Slider.setValue(PRESET_DANCE[5]);

equ6Slider.setValue(PRESET_DANCE[6]);

equ7Slider.setValue(PRESET_DANCE[7]);

equ8Slider.setValue(PRESET_DANCE[8]);

equ9Slider.setValue(PRESET_DANCE[9]);

}

if (event.getItem() == "Full Bass")

{

equ0Slider.setValue(PRESET_FULLBASS[0]);

equ1Slider.setValue(PRESET_FULLBASS[1]);

equ2Slider.setValue(PRESET_FULLBASS[2]);

equ3Slider.setValue(PRESET_FULLBASS[3]);

equ4Slider.setValue(PRESET_FULLBASS[4]);

equ5Slider.setValue(PRESET_FULLBASS[5]);

equ6Slider.setValue(PRESET_FULLBASS[6]);

equ7Slider.setValue(PRESET_FULLBASS[7]);

equ8Slider.setValue(PRESET_FULLBASS[8]);

equ9Slider.setValue(PRESET_FULLBASS[9]);

}

if (event.getItem() == "Full Treble")

{

equ0Slider.setValue(PRESET_FULLTREBLE[0]);

equ1Slider.setValue(PRESET_FULLTREBLE[1]);

equ2Slider.setValue(PRESET_FULLTREBLE[2]);

equ3Slider.setValue(PRESET_FULLTREBLE[3]);

equ4Slider.setValue(PRESET_FULLTREBLE[4]);

equ5Slider.setValue(PRESET_FULLTREBLE[5]);

equ6Slider.setValue(PRESET_FULLTREBLE[6]);

equ7Slider.setValue(PRESET_FULLTREBLE[7]);

equ8Slider.setValue(PRESET_FULLTREBLE[8]);

equ9Slider.setValue(PRESET_FULLTREBLE[9]);

}

if (event.getItem() == "Rock")

{

equ0Slider.setValue(PRESET_ROCK[0]);

equ1Slider.setValue(PRESET_ROCK[1]);

equ2Slider.setValue(PRESET_ROCK[2]);

equ3Slider.setValue(PRESET_ROCK[3]);

equ4Slider.setValue(PRESET_ROCK[4]);

equ5Slider.setValue(PRESET_ROCK[5]);

equ6Slider.setValue(PRESET_ROCK[6]);

equ7Slider.setValue(PRESET_ROCK[7]);

equ8Slider.setValue(PRESET_ROCK[8]);

equ9Slider.setValue(PRESET_ROCK[9]);

}

if (event.getItem() == "Techno")

{

equ0Slider.setValue(PRESET_TECHNO[0]);

equ1Slider.setValue(PRESET_TECHNO[1]);

equ2Slider.setValue(PRESET_TECHNO[2]);

equ3Slider.setValue(PRESET_TECHNO[3]);

equ4Slider.setValue(PRESET_TECHNO[4]);

equ5Slider.setValue(PRESET_TECHNO[5]);

equ6Slider.setValue(PRESET_TECHNO[6]);

equ7Slider.setValue(PRESET_TECHNO[7]);

equ8Slider.setValue(PRESET_TECHNO[8]);

equ9Slider.setValue(PRESET_TECHNO[9]);

}

}

}

public void stateChanged (ChangeEvent changeEvent)

{

//the stateChange is activated whenever a sliders value changes

JSlider source = (JSlider) changeEvent.getSource();

if (!source.getValueIsAdjusting())

{

if(source == volumeSlider)

{

gain= ((double)source.getValue())/10;

db= (float)(Math.log(gain)/Math.log(10.0)*20.0);

}

if(source == panSlider)

panContValue = ((float)source.getValue())/10;

if (source == timeSlider)

{ if (source.getValue() != (int)((timeSec/fileDuration)*1000)&& source.getValue() !=0)

{

skipFileBytesTemp = (long) ((source.getValue()* fileSizeByte)/1000);

System.out.println(skipFileBytesTemp);

double timeSecEskilerTemp = (fileDuration*source.getValue())/1000;

stopFile();

timeSecEskiler = timeSecEskilerTemp;

skipFileBytes = skipFileBytesTemp;

playFile(count);

}

}

if(source == equ0Slider)

equ0 = (float)(source.getValue()-50)/50;

if(source == equ1Slider)

equ1 = (float)(source.getValue()-50)/50;

if(source == equ2Slider)

equ2 = (float)(source.getValue()-50)/50;

if(source == equ3Slider)

equ3 = (float)(source.getValue()-50)/50;

if(source == equ4Slider)

equ4 = (float)(source.getValue()-50)/50;

if(source == equ5Slider)

equ5 = (float)(source.getValue()-50)/50;

if(source == equ6Slider)

equ6 = (float)(source.getValue()-50)/50;

if(source == equ7Slider)

equ7 = (float)(source.getValue()-50)/50;

if(source == equ8Slider)

equ8 = (float)(source.getValue()-50)/50;

if(source == equ8Slider)

equ9 = (float)(source.getValue()-50)/50;

}

}

public void actionPerformed (ActionEvent action)

{

if(action.getSource()== delete_btn)

{

int selectedFiles[] = playList1.getSelectedIndices();

nextCount = -1;

playList1.setToolTipText("Double left click to play, Double right click to enqueue.");

int k=0;

int j=0;

while(k<selectedFiles.length){

//System.out.println(k + "="+ selectedFiles[k]);

if (selectedFiles[k]-j != count){

list.remove(selectedFiles[k]-j);

listName.remove(selectedFiles[k]-j);

if (selectedFiles[k]-j < count) count--;

j++;

}

k++;

}

//System.out.println(count);

playList1.setListData(listName);

}

if(action.getSource()==deleteAll_btn)

{

play_btn.setEnabled (false);

pause_btn.setEnabled (false);

next_btn.setEnabled (false);

prev_btn.setEnabled (false);

stop_btn.setEnabled (false);

deleteAll_btn.setEnabled(false);

delete_btn.setEnabled(false);

nextCount = -1;

playList1.setToolTipText("Double left click to play, Double right click to enqueue.");

list.removeAllElements();

listName.removeAllElements();

playList1.setListData(listName);

stopFile();

MP3info.setText("");

count=0;

}

if(action.getSource() == addFolder_btn)

{

if (statusStoped == true || list.isEmpty()) play_btn.setEnabled (true);

chooseFolder();

if (list.isEmpty()==true) play_btn.setEnabled(false);

}

if(action.getSource () == add_btn)

{

if (statusStoped == true || list.isEmpty()) play_btn.setEnabled (true);

chooseFile();

if (list.isEmpty()==true) play_btn.setEnabled(false);

}

if (action.getSource()==play_btn)

{

next_btn.setEnabled (true);

prev_btn.setEnabled(true);

stop_btn.setEnabled (true);

pause_btn.setEnabled(true);

playFile(count);

}

if (action.getSource()==prev_btn)

{

statusStoped = true;

prevFile();

}

if (action.getSource()==next_btn)

{

statusStoped = true;

nextFile();

}

if (action.getSource()==stop_btn)

{

pause_btn.setEnabled(false);

statusPause = false;

statusStoped = true;

stopFile();

play_btn.setEnabled (true);

}

if (action.getSource()==pause_btn)

{

if (statusPause==false)

{

statusPause=true;

}

else if (statusPause==true)

{

statusPause=false;

}

}

/*if(action.getSource ()==exit_btn)

{

System.out.println("in exit_f event");

super.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);

super.dispose();

System.exit(0);

}*/

}

public void playFile(int a)

{

try

{

pause_btn.setEnabled(true);

play_btn.setEnabled (false);

statusStoped = false;

File temp=(File)list.get(a);

playList1.setSelectedIndex(count);

//find mp3 size in BYTES

fileSizeByte = temp.length();

//find MP3's audio info duration in sec

AudioFileFormat baseFileFormat = AudioSystem.getAudioFileFormat(temp);

if (baseFileFormat instanceof TAudioFileFormat)

{

Map properties = ((TAudioFileFormat)baseFileFormat).properties();

String key = "duration";

Object objectTemp = properties.get(key);

fileLength = Long.parseLong(objectTemp.toString());

fileDuration = (double)((fileLength/1000000));

key = "author";

artist = (String) properties.get(key);

key = "title";

title = (String) properties.get(key);

//System.out.println(""+ artist + title);

//System.out.println(fileDuration);

}

//create input stream

AudioInputStream in=AudioSystem.getAudioInputStream(temp);

AudioFormat baseFormat=in.getFormat();

AudioFormat decodeFormat= new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,

baseFormat.getSampleRate(),

16,

baseFormat.getChannels(),

baseFormat.getChannels() * 2,

baseFormat.getSampleRate(),

false);

din = AudioSystem.getAudioInputStream(decodeFormat, in);

din.skip(skipFileBytes);

DataLine.Info info= new DataLine.Info(SourceDataLine.class, decodeFormat);

line = (SourceDataLine) AudioSystem.getLine(info);

line.open(decodeFormat);

if (line != null)

{

nBytesRead = 0;

nBytesWritten = 0;

line.start();

Mp3Ready = true;

}

}

catch(Exception NoMP3)

{

System.out.println("gote geldin " + NoMP3.toString());

}

}

public void stopFile()

{

try{

Mp3Ready = false;

nBytesRead = -1;

skipFileBytes = 0;

timeSecEskiler = 0;

line.drain();

line.stop();

line.close();

din.close();

timeSlider.setValue(0);

MP3info.setText("ARTIST: " + artist + "\n" + "TITLE : " + title + "\n"

+ "TIME : ");

progressBar0.setValue(0);

progressBar1.setValue(0);

progressBar2.setValue(0);

progressBar3.setValue(0);

progressBar4.setValue(0);

progressBar5.setValue(0);

progressBar6.setValue(0);

progressBar7.setValue(0);

progressBar8.setValue(0);

progressBar9.setValue(0);

progressBar10.setValue(0);

progressBar11.setValue(0);

progressBar12.setValue(0);

progressBar13.setValue(0);

progressBar14.setValue(0);

progressBar15.setValue(0);

}

catch(Exception NoMP3) {

System.out.println("gote geldin " + NoMP3.toString());

}

}

public void nextFile(){

if(!(list.isEmpty())){

stopFile();

statusPause = false;

if (nextCount != -1){

count = nextCount;

nextCount = -1;

playList1.setToolTipText("Double left click to play, Double right click to enqueue.");

}

else {

if(count==(list.size()-1) && shuffleCheck.isSelected() == false)

count = 0;

else if (shuffleCheck.isSelected() == false && count != (list.size()-1))

count++;

else if (shuffleCheck.isEnabled() == true)

count = (int)(Math.random()*(list.size()-1));

//System.out.println(count);

}

playFile(count);

}}

public void prevFile(){

stopFile();

statusPause = false;

if(count!=0)

count--;

playFile(count);

}

class MyFilter extends javax.swing.filechooser.FileFilter {

public boolean accept(File file) {

return file.getName().toLowerCase().endsWith(".mp3") || file.getName().toLowerCase().endsWith(".mp3") || file.isDirectory();

}

public String getDescription() {

return "*.mp3";

}

}

public void chooseFolder()

{

JFileChooser chooseFolder = new JFileChooser();

chooseFolder.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

int result = chooseFolder.showOpenDialog(addFolder_btn);

if (result == JFileChooser.APPROVE_OPTION)

{

if (chooseFolder.getSelectedFile().isDirectory()) {

searchFolder(chooseFolder.getSelectedFile());

playList1.setListData(listName);

}

}

}

public void searchFolder(File folder){

File files [] = folder.listFiles();

//System.out.println(files[0].getName());

for (int i=0; i><files.length;i++) {

if (files [i].getName().toLowerCase().endsWith(".mp3")) {

list.add (files[i]);

listName.add (files [i].getName()); }

else if(files [i].isDirectory()){

searchFolder(files[i]);

}

}

}

public void chooseFile()

{

JFileChooser choose=new JFileChooser();

choose.addChoosableFileFilter(new MyFilter());

choose.setFileSelectionMode (JFileChooser.FILES_ONLY);

int result=choose.showOpenDialog (add_btn);

if(result==JFileChooser.APPROVE_OPTION)

{

File f=choose.getSelectedFile ();

if(f.exists ()==true && f.isFile ()==true)

{

list.add (f);

listName.add (f.getName());

playList1.setListData(listName);

}

else

JOptionPane.showMessageDialog (this,"invalid file selected","Invalid File",

JOptionPane.ERROR_MESSAGE);

}

}

void fft_1d( byte [] array1 )

{

double[][] array = new double [4096][2];

double u_r,u_i, w_r,w_i, t_r,t_i;

int ln, nv2, k, l, le, le1, j, ip, i, n;

double [] freq = new double [16];

//double [] freqHistory = new double [32];

double alpha = 0.2;

for (i=0; i><array1.length; i++)

{

array [i][0] = (double)array1 [i];

array [i] [1] = 0.0;

}

n = array.length;

ln = (int)( Math.log( (double)n )/Math.log(2) + 0.5 );

nv2 = n / 2;

j = 1;

for (i = 1; i >< n; i++ )

{

if (i < j)

{

t_r = array[i - 1][0];

t_i = array[i - 1][1];

array[i - 1][0] = array[j - 1][0];

array[i - 1][1] = array[j - 1][1];

array[j - 1][0] = t_r;

array[j - 1][1] = t_i;

}

k = nv2;

while (k < j)

{

j = j - k;

k = k / 2;

}

j = j + k;

}

for (l = 1; l <= ln; l++) /* loops thru stages */

{

le = (int)(Math.exp( (double)l * Math.log(2) ) + 0.5 );

le1 = le / 2;

u_r = 1.0;

u_i = 0.0;

w_r = Math.cos( Math.PI / (double)le1 );

w_i = -Math.sin( Math.PI / (double)le1 );

for (j = 1; j <= le1; j++) /* loops thru 1/2 twiddle values per stage */

{

for (i = j; i <= n; i += le) /* loops thru points per 1/2 twiddle */

{

ip = i + le1;

t_r = array[ip - 1][0] * u_r - u_i * array[ip - 1][1];

t_i = array[ip - 1][1] * u_r + u_i * array[ip - 1][0];

array[ip - 1][0] = array[i - 1][0] - t_r;

array[ip - 1][1] = array[i - 1][1] - t_i;

array[i - 1][0] = array[i - 1][0] + t_r;

array[i - 1][1] = array[i - 1][1] + t_i;

}

t_r = u_r * w_r - w_i * u_i;

u_i = w_r * u_i + w_i * u_r;

u_r = t_r;

}

}

for(int p=0; p<16; p++) {

for (int z=(128*p); z<(128*(p+1));z++) freq[p] = freq[p] + Math.sqrt(array[z][0]*array[z][0]+array[z][1]*array[z][1]);

freq[p] = freq[p]/4096;

freqHistory [p] = alpha * freqHistory[p] + ((1 - alpha) * freq[p]);

}

//System.out.println(freqHistory[0] + " 1");

//System.out.println((int) (Math.log(freqHistory[0])*20));

progressBar0.setValue((int) (Math.log(freqHistory[0])*20) - 40);

progressBar1.setValue((int) (Math.log(freqHistory[1])*20) - 10);

progressBar2.setValue((int) (Math.log(freqHistory[2])*20));

progressBar3.setValue((int) (Math.log(freqHistory[3])*20));

progressBar4.setValue((int) (Math.log(freqHistory[4])*20) - 5);

progressBar5.setValue((int) (Math.log(freqHistory[5])*20) - 5);

progressBar6.setValue((int) (Math.log(freqHistory[6])*20) - 5);

progressBar7.setValue((int) (Math.log(freqHistory[7])*20) - 5);

progressBar8.setValue((int) (Math.log(freqHistory[8])*20) - 10);

progressBar9.setValue((int) (Math.log(freqHistory[9])*20) - 15);

progressBar10.setValue((int) (Math.log(freqHistory[10])*20) - 20);

progressBar11.setValue((int) (Math.log(freqHistory[11])*20) - 30);

progressBar12.setValue((int) (Math.log(freqHistory[12])*20) - 40);

progressBar13.setValue((int) (Math.log(freqHistory[13])*20) - 55);

progressBar14.setValue((int) (Math.log(freqHistory[14])*20) - 70);

progressBar15.setValue((int) (Math.log(freqHistory[15])*20) - 85);

//System.out.println((int)(Math.sqrt(array[2][0]*array[2][0]+array[2][1]*array[2][1])));

}

public static void main(String arg[])

{

JavaMP3Player obj=new JavaMP3Player();

obj.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

private void initComponents() {

//JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents

//Generated using JFormDesigner Evaluation license - emre zorlu

tabbedPane1 = new JTabbedPane();

playListPane = new JPanel();

playListSPane = new JScrollPane();

playList1 = new JList();

add_btn = new JButton();

addFolder_btn = new JButton();

delete_btn = new JButton();

deleteAll_btn = new JButton();

shuffleCheck = new JCheckBox();

panelEqu = new JPanel();

equ0Slider = new JSlider();

equ1Slider = new JSlider();

equ2Slider = new JSlider();

equ3Slider = new JSlider();

equ4Slider = new JSlider();

equ5Slider = new JSlider();

equ6Slider = new JSlider();

equ7Slider = new JSlider();

equ8Slider = new JSlider();

equ9Slider = new JSlider();

panSlider = new JSlider();

equPreset = new JComboBox(presetNames);

equPreLabel = new JLabel();

db1Label = new JLabel();

db0Label = new JLabel();

db2Label = new JLabel();

panlLabel = new JLabel();

panrLabel = new JLabel();

equnumLabel = new JLabel();

prev_btn = new JButton();

play_btn = new JButton();

pause_btn = new JButton();

stop_btn = new JButton();

next_btn = new JButton();

progressBar0 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

progressBar1 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

progressBar2 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

progressBar3 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

progressBar4 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

progressBar5 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

progressBar6 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

progressBar7 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

progressBar8 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

progressBar9 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

progressBar10 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

progressBar11 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

progressBar12 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

progressBar13 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

progressBar14 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

progressBar15 = new JProgressBar(JProgressBar.VERTICAL,prog_Min,prog_Max);

volumeSlider = new JSlider();

scrollPane1 = new JScrollPane();

MP3info = new JTextArea();

timeSlider = new JSlider();

muteCheck = new JCheckBox();

vol1Label = new JLabel();

vol2Label = new JLabel();

vol3Label = new JLabel();

MP3infoLabel = new JLabel();

grapEquLabel = new JLabel();

bogusButton = new JButton();

//======== this ========

setResizable(false);

setTitle("Mp3Player v2.0.0");

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

Container contentPane = getContentPane();

contentPane.setLayout(null);

//======== tabbedPane1 ========

{

//======== playListPane ========

{

//JFormDesigner evaluation mark

playListPane.setBorder(new javax.swing.border.CompoundBorder(

new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0),

"JFormDesigner Evaluation", javax.swing.border.TitledBorder.CENTER,

javax.swing.border.TitledBorder.BOTTOM, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12),

java.awt.Color.red), playListPane.getBorder())); playListPane.addPropertyChangeListener(new java.beans.PropertyChangeListener(){public void propertyChange(java.beans.PropertyChangeEvent e){if("border".equals(e.getPropertyName()))throw new RuntimeException();}});

playListPane.setLayout(null);

//======== playListSPane ========

{

//- playList1 -

playList1.setToolTipText("Double left click to play, Double right click to enqueue.");

playListSPane.setViewportView(playList1);

}

playListPane.add(playListSPane);

playListSPane.setBounds(0, 0, 325, 165);

//- add_btn -

add_btn.setText("+File");

add_btn.setFont(new Font("Tahoma", Font.PLAIN, 9));

add_btn.setHorizontalAlignment(SwingConstants.LEFT);

add_btn.setToolTipText("Add file");

playListPane.add(add_btn);

add_btn.setBounds(0, 170, 60, 23);

//- addFolder_btn -

addFolder_btn.setText("+Folder");

addFolder_btn.setFont(new Font("Tahoma", Font.PLAIN, 9));

addFolder_btn.setHorizontalAlignment(SwingConstants.LEFT);

addFolder_btn.setToolTipText("Add Folder");

playListPane.add(addFolder_btn);

addFolder_btn.setBounds(58, 170, 70, 23);

//- delete_btn -

delete_btn.setText("-Remove");

delete_btn.setFont(new Font("Tahoma", Font.PLAIN, 9));

delete_btn.setHorizontalAlignment(SwingConstants.LEFT);

delete_btn.setToolTipText("Remove File");

playListPane.add(delete_btn);

delete_btn.setBounds(128, 170, 73, 23);

//- deleteAll_btn -

deleteAll_btn.setText("Clear");

deleteAll_btn.setFont(new Font("Tahoma", Font.PLAIN, 9));

deleteAll_btn.setHorizontalAlignment(SwingConstants.LEFT);

deleteAll_btn.setToolTipText("Delete All");

playListPane.add(deleteAll_btn);

deleteAll_btn.setBounds(201, 170, 59, 23);

//- shuffleCheck -

shuffleCheck.setText("Shuffle");

shuffleCheck.setFont(new Font("Tahoma", Font.PLAIN, 9));

shuffleCheck.setToolTipText("Shuffle Mode Enable/Disable");

playListPane.add(shuffleCheck);

shuffleCheck.setBounds(263, 171, 55, 23);

}

tabbedPane1.addTab("Playlist", null, playListPane, "Playlist");

//======== panelEqu ========

{

panelEqu.setToolTipText("Equalizer");

panelEqu.setLayout(null);

//- equ0Slider -

equ0Slider.setOrientation(JSlider.VERTICAL);

equ0Slider.setMajorTickSpacing(10);

equ0Slider.setMinorTickSpacing(2);

equ0Slider.setPaintTicks(true);

panelEqu.add(equ0Slider);

equ0Slider.setBounds(10, 40, 25, 140);

//- equ1Slider -

equ1Slider.setOrientation(JSlider.VERTICAL);

equ1Slider.setMajorTickSpacing(10);

equ1Slider.setMinorTickSpacing(2);

equ1Slider.setPaintTicks(true);

panelEqu.add(equ1Slider);

equ1Slider.setBounds(40, 40, 25, 140);

//- equ2Slider -

equ2Slider.setOrientation(JSlider.VERTICAL);

equ2Slider.setMajorTickSpacing(10);

equ2Slider.setMinorTickSpacing(2);

equ2Slider.setPaintTicks(true);

panelEqu.add(equ2Slider);

equ2Slider.setBounds(70, 40, 25, 140);

//- equ3Slider -

equ3Slider.setOrientation(JSlider.VERTICAL);

equ3Slider.setMajorTickSpacing(10);

equ3Slider.setMinorTickSpacing(2);

equ3Slider.setPaintTicks(true);

panelEqu.add(equ3Slider);

equ3Slider.setBounds(100, 40, 25, 140);

//- equ4Slider -

equ4Slider.setOrientation(JSlider.VERTICAL);

equ4Slider.setMajorTickSpacing(10);

equ4Slider.setMinorTickSpacing(2);

equ4Slider.setPaintTicks(true);

panelEqu.add(equ4Slider);

equ4Slider.setBounds(130, 40, 25, 140);

//- equ5Slider -

equ5Slider.setOrientation(JSlider.VERTICAL);

equ5Slider.setMajorTickSpacing(10);

equ5Slider.setMinorTickSpacing(2);

equ5Slider.setPaintTicks(true);

panelEqu.add(equ5Slider);

equ5Slider.setBounds(160, 40, 25, 140);

//- equ6Slider -

equ6Slider.setOrientation(JSlider.VERTICAL);

equ6Slider.setMajorTickSpacing(10);

equ6Slider.setMinorTickSpacing(2);

equ6Slider.setPaintTicks(true);

panelEqu.add(equ6Slider);

equ6Slider.setBounds(190, 40, 25, 140);

//- equ7Slider -

equ7Slider.setOrientation(JSlider.VERTICAL);

equ7Slider.setMajorTickSpacing(10);

equ7Slider.setMinorTickSpacing(2);

equ7Slider.setPaintTicks(true);

panelEqu.add(equ7Slider);

equ7Slider.setBounds(215, 40, 25, 140);

//- equ8Slider -

equ8Slider.setOrientation(JSlider.VERTICAL);

equ8Slider.setMajorTickSpacing(10);

equ8Slider.setMinorTickSpacing(2);

equ8Slider.setPaintTicks(true);

panelEqu.add(equ8Slider);

equ8Slider.setBounds(240, 40, 25, 140);

//- equ9Slider -

equ9Slider.setOrientation(JSlider.VERTICAL);

equ9Slider.setMajorTickSpacing(10);

equ9Slider.setMinorTickSpacing(2);

equ9Slider.setPaintTicks(true);

panelEqu.add(equ9Slider);

equ9Slider.setBounds(265, 40, 25, 140);

//- panSlider -

panSlider.setToolTipText("Pan Slider L/R (Double Click for Center)");

panSlider.setMaximum(10);

panSlider.setMinimum(-10);

panSlider.setValue(0);

panSlider.setPaintTicks(true);

panSlider.setMajorTickSpacing(10);

panelEqu.add(panSlider);

panSlider.setBounds(229, 0, 85, panSlider.getPreferredSize().height);

//- equPreset -

equPreset.setToolTipText("Select Equalizer Preset");

panelEqu.add(equPreset);

equPreset.setBounds(109, 0, 120, equPreset.getPreferredSize().height);

//- equPreLabel -

equPreLabel.setText("Equalizer Presets");

panelEqu.add(equPreLabel);

equPreLabel.setBounds(new Rectangle(new Point(5, 5), equPreLabel.getPreferredSize()));

//- db1Label -

db1Label.setText("+6Db");

db1Label.setFont(new Font("Tahoma", Font.BOLD, 11));

panelEqu.add(db1Label);

db1Label.setBounds(new Rectangle(new Point(290, 40), db1Label.getPreferredSize()));

//- db0Label -

db0Label.setText("0");

panelEqu.add(db0Label);

db0Label.setBounds(295, 105, 15, db0Label.getPreferredSize().height);

//- db2Label -

db2Label.setText("-6Db");

db2Label.setFont(new Font("Tahoma", Font.BOLD, 11));

panelEqu.add(db2Label);

db2Label.setBounds(new Rectangle(new Point(292, 165), db2Label.getPreferredSize()));

//- panlLabel -

panlLabel.setText("L");

panlLabel.setFont(new Font("Dialog", Font.BOLD, 10));

panelEqu.add(panlLabel);

panlLabel.setBounds(235, 25, 20, panlLabel.getPreferredSize().height);

//- panrLabel -

panrLabel.setText("R");

panrLabel.setFont(new Font("Dialog", Font.BOLD, 10));

panelEqu.add(panrLabel);

panrLabel.setBounds(304, 25, 20, panrLabel.getPreferredSize().height);

//- equnumLabel -

equnumLabel.setText("601703106001k3k6k12k14k16k");

equnumLabel.setFont(new Font("Dialog", Font.BOLD, 10));

panelEqu.add(equnumLabel);

equnumLabel.setBounds(12, 180, 290, equnumLabel.getPreferredSize().height);

}

tabbedPane1.addTab("Equalizer", panelEqu);

}

contentPane.add(tabbedPane1);

tabbedPane1.setBounds(305, 5, 330, 225);

//- prev_btn -

prev_btn.setText("\u25c4\u25c4");

prev_btn.setFont(new Font("Arial", Font.BOLD, 14));

prev_btn.setToolTipText("Previous");

contentPane.add(prev_btn);

prev_btn.setBounds(5, 200, 63, 23);

//- play_btn -

play_btn.setText("\u25ba");

play_btn.setFont(new Font("Arial", Font.PLAIN, 14));

play_btn.setToolTipText("Play");

contentPane.add(play_btn);

play_btn.setBounds(74, 200, 50, 23);

//- pause_btn -

pause_btn.setText("II");

pause_btn.setFont(new Font("Arial", Font.BOLD, 14));

pause_btn.setToolTipText("Pause");

contentPane.add(pause_btn);

pause_btn.setBounds(124, 200, 50, 23);

//- stop_btn -

stop_btn.setText("\u25a0");

stop_btn.setFont(new Font("Arial", Font.PLAIN, 16));

stop_btn.setVerticalAlignment(SwingConstants.BOTTOM);

stop_btn.setToolTipText("Stop");

contentPane.add(stop_btn);

stop_btn.setBounds(174, 200, 50, 23);

//- next_btn -

next_btn.setText("\u25ba\u25ba");

next_btn.setFont(new Font("Arial", Font.PLAIN, 14));

next_btn.setToolTipText("Forward");

contentPane.add(next_btn);

next_btn.setBounds(231, 200, 64, 23);

//- progressBar0 -

progressBar0.setOrientation(SwingConstants.VERTICAL);

contentPane.add(progressBar0);

progressBar0.setBounds(182, 30, 8, 120);

//- progressBar1 -

progressBar1.setOrientation(SwingConstants.VERTICAL);

contentPane.add(progressBar1);

progressBar1.setBounds(189, 30, 8, 120);

//- progressBar2 -

progressBar2.setOrientation(SwingConstants.VERTICAL);

contentPane.add(progressBar2);

progressBar2.setBounds(196, 30, 8, 120);

//- progressBar3 -

progressBar3.setOrientation(SwingConstants.VERTICAL);

contentPane.add(progressBar3);

progressBar3.setBounds(203, 30, 8, 120);

//- progressBar4 -

progressBar4.setOrientation(SwingConstants.VERTICAL);

contentPane.add(progressBar4);

progressBar4.setBounds(210, 30, 8, 120);

//- progressBar5 -

progressBar5.setOrientation(SwingConstants.VERTICAL);

contentPane.add(progressBar5);

progressBar5.setBounds(217, 30, 8, 120);

//- progressBar6 -

progressBar6.setOrientation(SwingConstants.VERTICAL);

progressBar6.setToolTipText("Graphic Equalizer");

contentPane.add(progressBar6);

progressBar6.setBounds(224, 30, 8, 120);

//- progressBar7 -

progressBar7.setOrientation(SwingConstants.VERTICAL);

progressBar7.setToolTipText("Graphic Equalizer");

contentPane.add(progressBar7);

progressBar7.setBounds(231, 30, 8, 120);

//- progressBar8 -

progressBar8.setOrientation(SwingConstants.VERTICAL);

progressBar8.setToolTipText("Graphic Equalizer");

contentPane.add(progressBar8);

progressBar8.setBounds(238, 30, 8, 120);

//- progressBar9 -

progressBar9.setOrientation(SwingConstants.VERTICAL);

progressBar9.setToolTipText("Graphic Equalizer");

contentPane.add(progressBar9);

progressBar9.setBounds(245, 30, 8, 120);

//- progressBar10 -

progressBar10.setOrientation(SwingConstants.VERTICAL);

progressBar10.setToolTipText("Graphic Equalizer");

contentPane.add(progressBar10);

progressBar10.setBounds(252, 30, 8, 120);

//- progressBar11 -

progressBar11.setOrientation(SwingConstants.VERTICAL);

progressBar11.setToolTipText("Graphic Equalizer");

contentPane.add(progressBar11);

progressBar11.setBounds(259, 30, 8, 120);

//- progressBar12 -

progressBar12.setOrientation(SwingConstants.VERTICAL);

progressBar12.setToolTipText("Graphic Equalizer");

contentPane.add(progressBar12);

progressBar12.setBounds(266, 30, 8, 120);

//- progressBar13 -

progressBar13.setOrientation(SwingConstants.VERTICAL);

progressBar13.setToolTipText("Graphic Equalizer");

contentPane.add(progressBar13);

progressBar13.setBounds(273, 30, 8, 120);

//- progressBar14 -

progressBar14.setOrientation(SwingConstants.VERTICAL);

progressBar14.setToolTipText("Graphic Equalizer");

contentPane.add(progressBar14);

progressBar14.setBounds(280, 30, 8, 120);

//- progressBar15 -

progressBar15.setOrientation(SwingConstants.VERTICAL);

progressBar15.setToolTipText("Graphic Equalizer");

contentPane.add(progressBar15);

progressBar15.setBounds(287, 30, 8, 120);

//- volumeSlider -

volumeSlider.setToolTipText("Volume");

volumeSlider.setMajorTickSpacing(5);

volumeSlider.setPaintTicks(true);

volumeSlider.setMaximum(10);

volumeSlider.setMinorTickSpacing(1);

volumeSlider.setValue(5);

contentPane.add(volumeSlider);

volumeSlider.setBounds(1, 116, 128, volumeSlider.getPreferredSize().height);

//======== scrollPane1 ========

{

//- MP3info -

MP3info.setToolTipText("Song information");

MP3info.setEditable(false);

MP3info.setBackground(new Color(184, 207, 229));

scrollPane1.setViewportView(MP3info);

}

contentPane.add(scrollPane1);

scrollPane1.setBounds(5, 30, 171, 81);

//- timeSlider -

timeSlider.setValue(0);

timeSlider.setPaintTicks(true);

timeSlider.setToolTipText("Time Slider");

timeSlider.setMaximum(1000);

contentPane.add(timeSlider);

timeSlider.setBounds(3, 165, 297, 35);

//- muteCheck -

muteCheck.setText("Mute");

muteCheck.setToolTipText("Mute Enable/Disable");

muteCheck.setFont(new Font("Dialog", Font.PLAIN, 10));

contentPane.add(muteCheck);

muteCheck.setBounds(129, 120, 50, muteCheck.getPreferredSize().height);

//- vol1Label -

vol1Label.setText("0%");

contentPane.add(vol1Label);

vol1Label.setBounds(new Rectangle(new Point(10, 145), vol1Label.getPreferredSize()));

//- vol2Label -

vol2Label.setText("50%");

contentPane.add(vol2Label);

vol2Label.setBounds(new Rectangle(new Point(65, 145), vol2Label.getPreferredSize()));

//- vol3Label -

vol3Label.setText("100%");

contentPane.add(vol3Label);

vol3Label.setBounds(new Rectangle(new Point(115, 145), vol3Label.getPreferredSize()));

//- MP3infoLabel -

MP3infoLabel.setText("Playing Song Information");

contentPane.add(MP3infoLabel);

MP3infoLabel.setBounds(new Rectangle(new Point(5, 10), MP3infoLabel.getPreferredSize()));

//- grapEquLabel -

grapEquLabel.setText("Graphic Equalizer");

contentPane.add(grapEquLabel);

grapEquLabel.setBounds(new Rectangle(new Point(183, 10), grapEquLabel.getPreferredSize()));

contentPane.add(bogusButton);

bogusButton.setBounds(149, 13, 3, 2);

{ // compute preferred size

Dimension preferredSize = new Dimension();

for(int i = 0; i < contentPane.getComponentCount(); i++) {

Rectangle bounds = contentPane.getComponent(i).getBounds();

preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);

preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);

}

Insets insets = contentPane.getInsets();

preferredSize.width += insets.right;

preferredSize.height += insets.bottom;

//((JComponent) contentPane).setPreferredSize( preferredSize );

}

//JFormDesigner - End of component initialization //GEN-END:initComponents

}

}

EmreZorlua at 2007-7-13 4:49:05 > top of Java-index,Other Topics,Algorithms...
# 11
thanks man, I have tried to write the equalizer using the class Capture/Playback of the JavaSoundDemo but it won't work.Have you made any improvements?Regards
relmoa at 2007-7-13 4:49:06 > top of Java-index,Other Topics,Algorithms...
# 12
I have managed to plot the mp3 file, but there's still a few improvments to be made.If interested I could post my code.Regards
relmoa at 2007-7-13 4:49:06 > top of Java-index,Other Topics,Algorithms...
# 13

Unfortunately not... I am working on the visual equalizer. The problem the time domain samples have too much noise. Therefore the frequency response of the samples are not accurate. I tried to take16384 samples but still the freq. response is not accurate. Does any one have suggestions about the program? I can post the new version but it is not that different. Also I can mail the jar file to any email if any one interested.

EmreZorlua at 2007-7-13 4:49:06 > top of Java-index,Other Topics,Algorithms...