Recent posts

#71
Rants and Raves / Windows 7 RC1
Last post by benthehutt - May 06, 2009, 11:18:32 AM
I just installed the Windows 7 RC. I'm kind of skeptical, but it seems to be doing better than Vista. Of course, Aero is beautiful, but I'm still undecided as to whether or not it's helpful. They've adopted some styles from Mac OSX as well as Ubuntu. Of course, Windows gadgets are Widgets from OSX, and the "View Desktop" button on the taskbar is straight from Ubuntu. However, the taskbar is a whole lot nicer, admittedly. Right clicking on programs running brings up a small menu of options and a list of items recently viewed with that program (if that applies). That's pretty handy. And there are very well executed thumbnails, and if you hover over a program on the taskbar, after about half a second, all programs fade away on the screen except for that one. I find it really pretty handy. I also like that balloon tips are not popping up everywhere.

My biggest complaint so far is that, by default, IPv4 and IPv6 protocols are running on each network card. This caused me problems, and I had to actually disable IPv6 to get connected to my router (which isn't that old). I'm not sure the average user would know this fix.

Anybody else use it yet? What do you think?
#72
General Discussion / Re: Godaigo's plea for help!
Last post by benthehutt - May 02, 2009, 11:46:43 AM
Yeah! That's a pretty sweet app. I'm more interested in actual synthesis than just adding sound files to an application. Anyway, I started some work on this, but I've got some questions on Java as a whole. What is the difference between Java and J2EE? Also, what good is the Runnable class? I've seen some examples where a guy instantiates a Runnable object and I don't know what the point was.

Here is my code so far. It's pretty simple, it just generates a sine wave and a square wave and plays them back. But let me know if I'm doing anything in Java that's stupid (I'm using Eclipse 3.4.1 Ganymede):

import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.LineUnavailableException;

import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;

public class BasicSound {
	
	// CD Quality audio (well, almost)
	public final float SAMPLE_RATE = 44100;
	
	// Main GUI component
	JFrame mainFrame; 
	
	public static void main( String[] args ){
		BasicSound my_sound = new BasicSound();
		my_sound.showDialog();
	}
	
	public BasicSound(){
		setUpDialog();
	}
	
	public void setUpDialog(){
	    // Main frame
	    mainFrame = new JFrame("Pure Wave Generator");
	    mainFrame.setSize( 300, 300 );
	    Container content = mainFrame.getContentPane();
	    content.setBackground(Color.white);
	    content.setLayout(new FlowLayout()); 
	    
	    // Frequency slider
	    final JSlider slider_hertz = new JSlider( JSlider.HORIZONTAL, 20, 20000, 440 );
	    slider_hertz.setPaintLabels( true );
	    slider_hertz.setToolTipText("In Hertz");
	    slider_hertz.setBorder( new TitledBorder( "Frequency" ) );
	    content.add( slider_hertz );
	    
	    // Sine wave button
	    final JButton btn_play_sine = new JButton( "Play Sine Wave" );
	    btn_play_sine.addActionListener( new ActionListener(){
	    	public void actionPerformed( ActionEvent actionEvent ){
	    		try{
	    			System.out.println("Play sine wave at " + slider_hertz.getValue() + " hertz.");
					generateSineWave( slider_hertz.getValue() );
				}catch( LineUnavailableException err ){
					System.out.println("Line is unavailable.");
				}
	    	}
	    } );
	    content.add( btn_play_sine );
	    
	    // Square wave button
	    final JButton btn_play_square = new JButton( "Play Square Wave" );
	    btn_play_square.addActionListener( new ActionListener(){
	    	public void actionPerformed( ActionEvent actionEvent ){
	    		try{
	    			System.out.println("Play square wave at " + slider_hertz.getValue() + " hertz.");
					generateSquareWave( slider_hertz.getValue() );
				}catch( LineUnavailableException err ){
					System.out.println("Line is unavailable.");
				}
	    	}
	    } );
	    content.add( btn_play_square );
	    
	    mainFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
	}
	
	public void showDialog(){
	    mainFrame.setVisible( true );
	}
	
	// Generate a sine wave at a specified frequency
	public void generateSineWave( float hertz ) throws LineUnavailableException{
	    byte[] buf = new byte[1];
	    
	    AudioFormat af = new AudioFormat( SAMPLE_RATE, 8, 1, true, false );
	    
    	SourceDataLine source_dl = AudioSystem.getSourceDataLine( af );
    	source_dl.open( af );
    	
    	for( int i=0; i < SAMPLE_RATE; i++ ){
      		double angle = i / ( SAMPLE_RATE / hertz ) * 2.0 * Math.PI;
      		buf[0]=( byte )( Math.sin( angle ) * 100 );
        	source_dl.write( buf, 0, 1 );
		}
		
		System.out.println("Finished playback.");
		
		source_dl.start();
		source_dl.drain();
		source_dl.stop();
		source_dl.close();
	}
	
	// Generate a square wave at a specified frequency
	public void generateSquareWave( float hertz ) throws LineUnavailableException{
	    byte[] buf = new byte[1];
	    
	    AudioFormat af = new AudioFormat( SAMPLE_RATE, 8, 1, true, false );
	    
    	SourceDataLine source_dl = AudioSystem.getSourceDataLine( af );
    	source_dl.open( af );
    	
    	for( int i=0; i < SAMPLE_RATE; i++ ){
      		double angle = i / ( SAMPLE_RATE / hertz ) * 2.0 * Math.PI;
      		buf[0]=( byte )( ( Math.sin( angle ) > 0 ) ? 100 : -100  );
        	source_dl.write( buf, 0, 1 );
		}
		
		System.out.println("Finished playback.");
		
		source_dl.start();
		source_dl.drain();
		source_dl.stop();
		source_dl.close();
	}
	
}


Also, what is the difference between an ActionListener and an EventListener?

Any help would be appreciated. Thanks!
#73
General Discussion / Re: Godaigo's plea for help!
Last post by godaigo - May 02, 2009, 01:18:21 AM
#74
General Discussion / Re: Godaigo's plea for help!
Last post by godaigo - May 02, 2009, 01:16:29 AM
I don't really, other than I started to look into what sound libraries were out there for my last final. I was planning on adding some simple sound effects to an app. but ran out of time, it was all extra credit stuff. I did see a lot of classes that would allow you to import various sound file types, pretty basic code, but I'm not 100% sure that it's the type of thing that you're talking about? I'll do some checking and get back to you!
#75
Firewalls / Re: How do I disable the firew...
Last post by benthehutt - May 01, 2009, 11:13:24 PM
If you need to disable the Windows XP built-in firewall, try here: http://support.microsoft.com/kb/283673.

I'm not sure exactly what you are needing, though. Could you post what program you're trying to load, or what exactly it is saying?
#76
Windows / Re: How to know if your window...
Last post by benthehutt - May 01, 2009, 10:29:27 PM
Okay, let's only post questions once from now on. Try http://www.microsoft.com/genuine/. Click on the "Validate Windows" button.
#77
Firewalls / How do I disable the firewalls...
Last post by xqxqpo - May 01, 2009, 07:59:10 PM
I already have a program I bought for my computer that is good for 2 computers. The second computer will not let us have the firewall or the clean up feature. They said I may have other conflicting firewalls on here. How do I get rid of excess firewalls, and all their properties?
#78
Windows / How to know if your windows xp...
Last post by xqxqpo - May 01, 2009, 07:57:23 PM
How to know if your windows xp 2000 is legal or illegal?How to know if your windows xp 2000 is legal or illegal?How to know if your windows xp 2000 is legal or illegal?How to know if your windows xp 2000 is legal or illegal?How to know if your windows xp 2000 is legal or illegal?
#79
General Discussion / Re: Godaigo's plea for help!
Last post by benthehutt - April 30, 2009, 04:24:11 PM
Well I'm starting some research into writing a synthesizer in Java. I'm all in to math, so I'd like to try my hand at Fourier synthesis and some related stuff. Do you have any experience with low level Java sound programming? I see audio synthesis libraries all around, but I'd like to write a Fourier synthesizer from scratch.
#80
General Discussion / Re: Godaigo's plea for help!
Last post by godaigo - April 30, 2009, 02:32:45 PM
I've actually just enrolled in school again. I figured a third degree couldn't hurt. So I'll finish up the CS and get that done with. Mostly I've been working with Java recently, nothing too terribly complicated though. It would be great to get something going though. I would love to get back into the swing of things and do some serious coding before I forget everything! Keep me posted if you have any ideas!
SMF spam blocked by CleanTalk