Skip to content

Latest commit

 

History

History
85 lines (65 loc) · 3.62 KB

File metadata and controls

85 lines (65 loc) · 3.62 KB

AlexKent Support me joining PI Network app with invitation code AlexKent AlexKent


About

Are you curious on how to make spectrum analysers in Java? Well the below tutorials plus the above code are the solution .

Java Spectrum Analyser Tutorial

Java Audio Tutorials and API's by GOXR3PLUS STUDIO

Example Usage ( Hey check here ):

import javafx.application.Application;
import javafx.scene.Cursor;
import javafx.scene.Scene;
import javafx.stage.Stage;

import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileNameExtensionFilter;

public class Main extends Application {

	PlayerExample playerExample = new PlayerExample();

	@Override
	public void start(Stage primaryStage) {
		try {

			// Scene
			Scene scene = new Scene(playerExample, 600, 600);
			scene.setCursor(Cursor.HAND);
			primaryStage.setScene(scene);

			// Show
			primaryStage.setOnCloseRequest(c -> System.exit(0));
			primaryStage.show();

			// Selection of song to play
			JFileChooser jFileChooser = new JFileChooser();
			jFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
			jFileChooser.setFileFilter(new FileNameExtensionFilter("audio","mp3","wav"));
			jFileChooser.setAcceptAllFileFilterUsed(false);

			while(true){
				if(jFileChooser.showOpenDialog(null)==JFileChooser.APPROVE_OPTION){
					playerExample.playSong(jFileChooser.getSelectedFile());
					break;
				} else{
					JOptionPane.showMessageDialog(null,"Please choose audio file","Select audio",
							JOptionPane.INFORMATION_MESSAGE);
				}
			}

		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}

	public static void main(String[] args) {
		launch(args);
	}
}